App-Cmdline
view release on metacpan or search on metacpan
t/01-testapp.t view on Meta::CPAN
#!/usr/bin/env perl
use strict;
use warnings;
package TestApp;
use parent 'App::Cmdline';
use Data::Dumper;
#use Test::More qw(no_plan);
use Test::More tests => 11;
BEGIN {
diag( "Inside TestApp" );
}
sub opt_spec {
my $self = shift;
ok (1);
my @got = $self->composed_of ([]);
is (scalar @got, 2, "Wrong array size");
is_deeply ($got[0], [], "No options given");
ok (ref ($got[-1]), "Reference expected");
is (ref ($got[-1]), 'HASH', "HASH reference expected");
is_deeply ($got[-1]->{getopt_conf},
['no_bundling', 'no_ignore_case', 'auto_abbrev'],
"Default getopt_conf");
@got = $self->composed_of ('App::Cmdline::Options::Basic');
is (scalar @got, 3, "(2) Wrong array size");
ok (ref ($got[0]), "(2) Reference expected");
is (ref ($got[0]), 'ARRAY', "ARRAY reference expected");
is (scalar @{$got[0]}, 2, "(3) Wrong array size");
is ($got[0]->[0], 'h', "-h expected");
return @got;
}
sub execute {
my ($self, $opt, $args) = @_;
}
1;
package main;
TestApp->import()->run();
#TestApp->run();
__END__
# Define your own options, and add some predefined sets.
sub opt_spec {
my $self = shift;
return $self->check_for_duplicates (
[ 'check|c' => "only check the configuration" ],
[],
$self->composed_of (
'App::Cmdline::Options::ExtDB',
[],
'App::Cmdline::Options::Basic',
)
);
}
# sub opt_spec {
# my $self = shift;
# my @db_options = $self->composed_of ('App::Cmdline::Options::Basic');
# pop @db_options;
( run in 0.717 second using v1.01-cache-2.11-cpan-99c4e6809bf )