Cache the Term::ReadLine input device. On some systems, it has to be cached, otherwise you end up trying to open too many input handles or something like that. This also means we can have session history where available.

This commit is contained in:
ian%hixie.ch 2002-05-26 15:03:48 +00:00
Родитель 8ffd16f0b1
Коммит 78a7589fdc
1 изменённых файлов: 11 добавлений и 3 удалений

Просмотреть файл

@ -100,10 +100,9 @@ sub createArgument {
} else {
$self->app->output->request(@_);
# get input from user
my $term = Term::ReadLine->new($self->app->name);
my $term = $self->term();
my $value = $term->readline(''); # (the parameter passed is the prompt, if any)
# if we cached the input device:
# $term->addhistory($value);
$term->addhistory($value);
if (defined($value)) {
if ($value eq '') {
# use default
@ -120,6 +119,15 @@ sub createArgument {
}
}
# internal method: returns a Term::ReadLine interface
sub term {
my $self = shift;
if (not defined($self->{'term'})) {
$self->{'term'} = Term::ReadLine->new($self->app->name);
}
return $self->{'term'};
}
# XXX Grrrr: