David Wheeler wrote:
> On Apr 8, 2006, at 03:32, Randy W. Sims wrote:
>
>> my $answer;
>> $answer = Prompter->ask(
>> prompt => "What is your favorite programming language?\n",
>> options => [qw(Perl Ruby Lua Python C C++)],
>> default => 'unknown',
>> show_options => 1,
>> show_default => 0,
>> );
>>
>> print "Answer: $answer\n";
>
>
> This actually looks similar to a method I wrote in my subclass. I think
> that you might find my "environ" and "callback" options useful additions:
Thanks! There are some usefull ideas here. I'll probably keep things
simple for the 0.28 release, but I definately see things like tieing it
into the new options in the next release.
Might possibly go ahead and add the callback; this very much echos the
options interface. It has a multi-option type, and callbacks via the
on_validate handler. OTOH, the user could do this via.
my $need_answer = 1;
while ($need_answer) {
my $ans = $mb->ask(...);
$need_answer = !valid_answer( $ans );
}
So a handler only adds a little bit of sugar...
Randy.
|