NAME

Term::UI - Term::ReadLine UI made easy

SYNOPSIS

use Term::UI;
use Term::ReadLine;

my $term = Term::ReadLine->new('brand');

my $reply = $term->get_reply(
                prompt => 'What is your favourite colour?',
                choices => [qw|blue red green|],
                default => 'blue',
);

my $bool = $term->ask_yn(
                    prompt => 'Do you like cookies?',
                    default => 'y',
            );


my $string = q[some_command -option --no-foo --quux='this thing'];

my ($options,$munged_input) = $term->parse_options($string);


### don't have Term::UI issue warnings -- default is '1'
$Term::UI::VERBOSE = 0;

### always pick the default (good for non-interactive terms)
### -- default is '0'
$Term::UI::AUTOREPLY = 1;

### Retrieve the entire session as a printable string:
$hist = Term::UI::History->history_as_string;
$hist = $term->history_as_string;

DESCRIPTION

Term::UI is a transparent way of eliminating the overhead of having to format a question and then validate the reply, informing the user if the answer was not proper and re-issuing the question.

Simply give it the question you want to ask, optionally with choices the user can pick from and a default and Term::UI will DWYM.

For asking a yes or no question, there's even a shortcut.

HOW IT WORKS

Term::UI places itself at the back of the Term::ReadLine @ISA array, so you can call its functions through your term object.

Term::UI uses Term::UI::History to record all interactions with the commandline. You can retrieve this history, or alter the filehandle the interaction is printed to. See the Term::UI::History manpage or the SYNOPSIS for details.

METHODS