view release on metacpan or search on metacpan
- production release; no code changes
0.11_03 2010/12/18
- encoding tweak for help
0.11_02 2010/10/02
- make sure classes are unloaded after their availability are
confirmed (except those that are loaded before the check)
0.11_01 2010/10/02
- use more Try::Tiny
0.10 2010/09/29
- no code changes
- added Try::Tiny dependency, hoping to catch test errors correctly
0.09 2010/09/23
- added run_directly method, which would be handy if you prefer
writing a set of independent scripts to writing one dispatcher
script.
0.08 2010/08/09
- now CLI::Dispatch can accept multiple namespaces in which it
looks for subcommands.
- noted an example to provide a subcommand aliases.
"requires" : {
"Class::Inspector" : "0",
"Class::Unload" : "0",
"Encode" : "0",
"Getopt::Long" : "0",
"Log::Dump" : "0.10",
"Path::Tiny" : "0",
"Pod::Simple" : "0",
"String::CamelCase" : "0",
"Term::Encoding" : "0",
"Try::Tiny" : "0"
}
}
},
"release_status" : "stable",
"resources" : {
"repository" : {
"url" : "https://github.com/charsbar/cli-dispatch"
}
},
"version" : "0.21"
requires:
Class::Inspector: '0'
Class::Unload: '0'
Encode: '0'
Getopt::Long: '0'
Log::Dump: '0.10'
Path::Tiny: '0'
Pod::Simple: '0'
String::CamelCase: '0'
Term::Encoding: '0'
Try::Tiny: '0'
resources:
repository: https://github.com/charsbar/cli-dispatch
version: '0.21'
requires 'Class::Inspector';
requires 'Class::Unload';
requires 'Encode';
requires 'Getopt::Long';
requires 'Log::Dump', '0.10';
requires 'Path::Tiny';
requires 'Pod::Simple';
requires 'String::CamelCase';
requires 'Term::Encoding';
requires 'Try::Tiny';
on test => sub {
requires 'Test::Classy', '0.04';
requires 'Test::More', '0.47';
requires 'Test::UseAllModules', '0.15';
};
on configure => sub {
requires 'ExtUtils::MakeMaker::CPANfile' => '0.07';
};
lib/CLI/Dispatch.pm view on Meta::CPAN
package CLI::Dispatch;
use strict;
use warnings;
use Carp;
use Getopt::Long ();
use String::CamelCase;
use Try::Tiny;
our $VERSION = '0.21';
# you may want to override these three methods.
sub options {qw( help|h|? verbose|v debug logfilter=s )}
sub default_command { 'help' }
sub get_command {
lib/CLI/Dispatch/Help.pm view on Meta::CPAN
use strict;
use warnings;
use base qw( CLI::Dispatch::Command );
use Class::Unload;
use Class::Inspector;
use Encode;
use Pod::Simple::Text;
use Path::Tiny;
use String::CamelCase;
use Term::Encoding ();
use Try::Tiny;
my $term_encoding = eval {
find_encoding(Term::Encoding::get_encoding())
} || 'utf8';
sub options {qw( from|decode=s to|encode=s )}
sub extra_namespaces {}
t/lib/CLIDTestClass/Basic/Basic.pm view on Meta::CPAN
package CLIDTestClass::Basic::Basic;
use strict;
use warnings;
use Test::Classy::Base;
use CLI::Dispatch;
use Try::Tiny;
sub simple_dispatch : Test {
my $class = shift;
my $ret = $class->dispatch(qw( simple ));
ok $ret eq 'simple', $class->message("dispatch succeeded: $ret");
}
sub simple_with_args : Test {
t/lib/CLIDTestClass/Basic/Help.pm view on Meta::CPAN
package CLIDTestClass::Basic::Help;
use strict;
use warnings;
use Test::Classy::Base;
use CLI::Dispatch;
use File::Spec;
use Try::Tiny;
sub list : Tests(4) {
my $class = shift;
$class->_command_list;
}
sub list_with_help_command : Tests(4) {
my $class = shift;
t/lib/CLIDTestClass/Check/Basic.pm view on Meta::CPAN
package CLIDTestClass::Check::Basic;
use strict;
use warnings;
use Test::Classy::Base;
use CLI::Dispatch;
use Try::Tiny;
sub simple_dispatch : Test {
my $class = shift;
my $ret = $class->dispatch(qw( simple ));
ok $ret =~ /for some reasons/, $class->message("dispatch succeeded: $ret");
}
sub simple_with_args : Test {
t/lib/CLIDTestClass/Check/Help.pm view on Meta::CPAN
package CLIDTestClass::Check::Help;
use strict;
use warnings;
use Test::Classy::Base;
use CLI::Dispatch;
use File::Spec;
use Try::Tiny;
sub list : Tests(5) {
my $class = shift;
$class->_command_list;
}
sub list_with_help_command : Tests(5) {
my $class = shift;
t/lib/CLIDTestClass/CustomLogger/Basic.pm view on Meta::CPAN
package CLIDTestClass::CustomLogger::Basic;
use strict;
use warnings;
use Test::Classy::Base;
use Try::Tiny;
sub initialize {
my $class = shift;
try { require IO::Capture::Stderr }
catch { $class->skip_this_class('this test requires IO::Capture') };
try { require Log::Handler }
catch { $class->skip_this_class('this test requires Log::Handler') };
}
sub no_args : Test {
t/lib/CLIDTestClass/Directly/Basic.pm view on Meta::CPAN
package CLIDTestClass::Directly::Basic;
use strict;
use warnings;
use Test::Classy::Base;
use Try::Tiny;
sub no_args : Test {
my $class = shift;
my $ret = $class->dispatch();
ok $ret eq 'no args', $class->message("dispatch succeeded: $ret");
}
sub with_args : Test {
t/lib/CLIDTestClass/Directly/Help.pm view on Meta::CPAN
package CLIDTestClass::Directly::Help;
use strict;
use warnings;
use Test::Classy::Base;
use File::Spec;
use Try::Tiny;
sub help_command : Test {
my $class = shift;
my $ret = $class->dispatch(qw( help ));
ok $ret eq 'help', $class->message('help command is ignored');
}
sub help_option : Tests(2) {
t/lib/CLIDTestClass/Error/Basic.pm view on Meta::CPAN
package CLIDTestClass::Error::Basic;
use strict;
use warnings;
use Test::Classy::Base;
use CLIDTest::Error;
use Try::Tiny;
sub simple_dispatch : Test {
my $class = shift;
my $ret = $class->dispatch(qw( simple ));
return $class->abort_this_test('obscure error') if $ret eq 'Obscure error';
ok $ret =~ /Compilation failed/, $class->message("dispatch succeeded: $ret");
}
t/lib/CLIDTestClass/Error/Help.pm view on Meta::CPAN
package CLIDTestClass::Error::Help;
use strict;
use warnings;
use Test::Classy::Base;
use CLIDTest::Error;
use File::Spec;
use Try::Tiny;
sub list : Tests(5) {
my $class = shift;
$class->_command_list;
}
sub list_with_help_command : Tests(5) {
my $class = shift;
t/lib/CLIDTestClass/Inline/Basic.pm view on Meta::CPAN
package CLIDTestClass::Inline::Basic;
use strict;
use warnings;
use Test::Classy::Base;
use CLIDTest::Inline;
use Try::Tiny;
sub simple_dispatch : Test {
my $class = shift;
my $ret = $class->dispatch(qw( simple ));
ok $ret eq 'simple', $class->message("dispatch succeeded: $ret");
}
sub simple_with_args : Test {
t/lib/CLIDTestClass/Log/Basic.pm view on Meta::CPAN
package CLIDTestClass::Log::Basic;
use strict;
use warnings;
use Test::Classy::Base;
use Try::Tiny;
sub initialize {
my $class = shift;
try { require IO::Capture::Stderr }
catch { $class->skip_this_class('this test requires IO::Capture') };
}
sub no_args : Test {
my $class = shift;
t/lib/CLIDTestClass/More/Alias.pm view on Meta::CPAN
package CLIDTestClass::More::Alias;
use strict;
use warnings;
use Test::Classy::Base;
use CLIDTest::More;
use Try::Tiny;
sub simple_dispatch : Test {
my $class = shift;
my $ret = $class->dispatch(qw( s ));
ok $ret eq 'simple', $class->message("dispatch succeeded: $ret");
}
sub simple_with_args : Test {
t/lib/CLIDTestClass/More/Basic.pm view on Meta::CPAN
package CLIDTestClass::More::Basic;
use strict;
use warnings;
use Test::Classy::Base;
use CLIDTest::More;
use Try::Tiny;
sub simple_dispatch : Test {
my $class = shift;
my $ret = $class->dispatch(qw( simple ));
ok $ret eq 'simple', $class->message("dispatch succeeded: $ret");
}
sub simple_with_args : Test {
t/lib/CLIDTestClass/More/Help.pm view on Meta::CPAN
package CLIDTestClass::More::Help;
use strict;
use warnings;
use Test::Classy::Base;
use CLIDTest::More;
use File::Spec;
use Try::Tiny;
sub list : Tests(5) {
my $class = shift;
$class->_command_list;
}
sub list_with_help_command : Tests(5) {
my $class = shift;
t/lib/CLIDTestClass/Multi/Basic.pm view on Meta::CPAN
package CLIDTestClass::Multi::Basic;
use strict;
use warnings;
use Test::Classy::Base;
use CLI::Dispatch;
use Try::Tiny;
sub simple_dispatch : Test {
my $class = shift;
my $ret = $class->dispatch(qw( simple ));
ok $ret eq 'simple', $class->message("dispatch succeeded: $ret");
}
sub simple_with_args : Test {
t/lib/CLIDTestClass/Multi/Help.pm view on Meta::CPAN
package CLIDTestClass::Multi::Help;
use strict;
use warnings;
use Test::Classy::Base;
use CLI::Dispatch;
use File::Spec;
use Try::Tiny;
sub list : Tests(6) {
my $class = shift;
$class->_command_list;
}
sub list_with_help_command : Tests(6) {
my $class = shift;
t/lib/CLIDTestClass/Single/Basic.pm view on Meta::CPAN
package CLIDTestClass::Single::Basic;
use strict;
use warnings;
use Test::Classy::Base;
use CLIDTest::Single;
use Try::Tiny;
sub no_args : Test {
my $class = shift;
my $ret = $class->dispatch();
ok $ret eq 'no args', $class->message("dispatch succeeded: $ret");
}
sub with_args : Test {
t/lib/CLIDTestClass/Single/Help.pm view on Meta::CPAN
package CLIDTestClass::Single::Help;
use strict;
use warnings;
use Test::Classy::Base;
use CLIDTest::Single;
use File::Spec;
use Try::Tiny;
sub help_command : Test {
my $class = shift;
my $ret = $class->dispatch(qw( help ));
ok $ret eq 'help', $class->message('help command is ignored');
}
sub help_option : Tests(2) {
t/lib/CLIDTestClass/Sub/Basic.pm view on Meta::CPAN
package CLIDTestClass::Sub::Basic;
use strict;
use warnings;
use Test::Classy::Base;
use CLI::Dispatch;
use Try::Tiny;
sub simple_dispatch : Test {
my $class = shift;
my $ret = $class->dispatch(qw( simple ));
ok $ret eq 'simple', $class->message("dispatch succeeded: $ret");
}
sub simple_with_args : Test {
t/lib/CLIDTestClass/Sub/Help.pm view on Meta::CPAN
package CLIDTestClass::Sub::Help;
use strict;
use warnings;
use Test::Classy::Base;
use CLI::Dispatch;
use File::Spec;
use Try::Tiny;
sub list : Tests(6) {
my $class = shift;
$class->_command_list;
}
sub list_with_help_command : Tests(6) {
my $class = shift;
t/lib/CLIDTestClass/Sub/SubHelp.pm view on Meta::CPAN
package CLIDTestClass::Sub::SubHelp;
use strict;
use warnings;
use Test::Classy::Base;
use CLI::Dispatch;
use File::Spec;
use Try::Tiny;
sub list : Tests(5) {
my $class = shift;
$class->_command_list(qw( cmd ));
}
sub list_with_help_command : Tests(5) {
my $class = shift;
t/lib/CLIDTestClass/Sub/Subcmd.pm view on Meta::CPAN
package CLIDTestClass::Sub::Subcmd;
use strict;
use warnings;
use Test::Classy::Base;
use CLI::Dispatch;
use Try::Tiny;
sub simple_dispatch : Test {
my $class = shift;
my $ret = $class->dispatch(qw( cmd simple_sub ));
ok $ret eq 'simple subcommand', $class->message("dispatch succeeded: $ret");
}
sub simple_with_args : Test {