Getopt-EX-Hashed
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
t/08_must.t view on Meta::CPAN
must => sub {
grep { lc($_[1]) eq $_ } qw(life universe everything);
};
has nature => spec => '=s%', default => {},
must => sub {
grep { lc($_[2]) eq $_ } qw(paranoid);
};
VALID: {
local @ARGV = qw(--answer 42
--answer-is 42
-q life
-q universe
-q everything
--nature Marvin=Paranoid
);
my $app = Getopt::EX::Hashed->new() or die;
GetOptions($app->optspec); # or die;
is($app->{answer}, 42, "Number");
is($app->{answer_is}, "Answer is 42", "Number with action");
is_deeply($app->{question}, [ "life", "universe", "everything" ], "List");
is($app->{nature}->{Marvin}, "Paranoid", "Hash");
}
INVALID: {
local @ARGV = qw(--answer 41
--answer-is 41
-q life
-q space
-q everything
-nature Marvin=Sociable
);
# has [ qw(+answer +answer_is +question +nature) ] => must => undef;
my $app = Getopt::EX::Hashed->new() or die;
t/09_validate.t view on Meta::CPAN
has mouse => '=s',
any => [ qw(Frankie Benjy) ];
has mice => ':s',
any => [ qw(Frankie Benjy), '' ];
} no Getopt::EX::Hashed;
VALID: {
local @ARGV = qw(--answer 42
--answer-is 42
--question life
--nature Marvin=Paranoid
--nature Zaphod=Sociable
--mouse Benjy
--mice
);
my $app = Getopt::EX::Hashed->new;
$app->getopt;
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.090 second using v1.00-cache-2.02-grep-82fe00e-cpan-da92000dfeb )