| 1 | use 5.008008; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | |||
| 5 | package Ask::Functions; | ||
| 6 | |||
| 7 | our $AUTHORITY = 'cpan:TOBYINK'; | ||
| 8 | our $VERSION = '0.015'; | ||
| 9 | |||
| 10 | use Exporter::Shiny qw( | ||
| 11 | info warning error entry question file_selection | ||
| 12 | single_choice multiple_choice | ||
| 13 | ); | ||
| 14 | |||
| 15 | sub _exporter_validate_opts { | ||
| 16 | my ( $class, $opts ) = @_; | ||
| 17 | |||
| 18 | $opts->{'backend'} ||= do { require Ask; 'Ask'->detect }; | ||
| 19 | $opts->{'backend'}->is_usable or die; | ||
| 20 | } | ||
| 21 | |||
| 22 | for my $f ( our @EXPORT_OK ) { | ||
| 23 | no strict 'refs'; | ||
| 24 | *{"_generate_$f"} = sub { | ||
| 25 | my ( $class, $name, $args, $opts ) = @_; | ||
| 26 | my $backend = $opts->{'backend'}; | ||
| 27 | return sub { $backend->$f( @_ % 2 ? ( text => @_ ) : @_ ) }; | ||
| 28 | }; | ||
| 29 | } | ||
| 30 | |||
| 31 | 1; | ||
| 32 | |||
| 33 | __END__ |