Getopt-Alt
view release on metacpan or search on metacpan
lib/Getopt/Alt.pm view on Meta::CPAN
{
helper => $self->helper,
%{$options}, ## no critic
options =>
$self->options, # inherit this objects options
default =>
{ %{ $self->opt }, %{ $options->{default} || {} } },
},
$opt_args
);
local @ARGV = ();
if ( $self->opt->auto_complete ) {
push @args, '--auto-complete', $self->opt->auto_complete,
'--';
}
$sub_obj->process(@args);
$self->opt( $sub_obj->opt );
$self->files( $sub_obj->files );
}
}
elsif (
t/auto_complete.t view on Meta::CPAN
},
},
[
'out|o=s',
'other|t=s',
]
)
};
my $err = $@;
ok !$err, 'No errors' or diag explain $err;
local @ARGV = qw/cm/;
my ($stdout, $stderr) = capture { $opt->complete([]) };
is $stdout, 'cmd', 'Suggests the correct command';
@ARGV = qw//;
($stdout, $stderr) = capture { $opt->complete([]) };
is $stdout, '2nd cmd', 'Suggests the correct command';
}
sub arguments {
diag 'arguments';
t/auto_complete.t view on Meta::CPAN
default => {
other => 'global default',
},
},
[
'out|o=s',
'other|t=s',
]
)
};
local @ARGV = qw/-/;
my ($stdout, $stderr) = capture { $opt->complete([]) };
is $stdout, '--help --man --other --out --version -o -t', 'Suggests the correct arguments';
@ARGV = qw/--/;
($stdout, $stderr) = capture { $opt->complete([]) };
is $stdout, '--help --man --other --out --version', 'Suggests the correct arguments';
}
sub general {
diag 'general';
t/get_options.t view on Meta::CPAN
use List::Util qw/sum/;
use Test::More;
use Test::Warnings qw/warning/;
use Getopt::Alt qw/get_options/;
our $VERSION = 0.123;
my @data = data();
for my $data (@data) {
for my $test ( @{ $data->{tests} } ) {
local @ARGV = @{ $test->{argv} };
if ( $test->{error} ) {
my $error;
my $warning = warning { eval { get_options( @{ $data->{args} } ) }; $error = $@; };
$warning = '' if ref $warning eq 'ARRAY' && @$warning == 0;
# error in windows where something is getting a permissions denied error
$error = $error->[0] if ref $error eq 'ARRAY' && $error->[1] =~ /Permission denied/;
like "$error", $test->{error}, "'$test->{name}': Fails as expected"
( run in 0.589 second using v1.01-cache-2.11-cpan-49f99fa48dc )