Revision history for Perl extension MooseX-Getopt
{{$NEXT}}
+ - -h is also treated as a --help option
0.45 2012-05-13 09:49:58 PDT-0700
- use Path::Class in test to avoid test failures on MSWin32 with filename
-?
--?
+ -h
--help
--usage
traits => ['NoGetopt'],
);
- # captures the options: --help --usage --? -?
+ # captures the options: --help --usage --? -? -h
has help_flag => (
is => 'ro', isa => 'Bool',
traits => ['Getopt'],
cmd_flag => 'help',
- cmd_aliases => [ qw(usage ?) ],
+ cmd_aliases => [ qw(usage ? h) ],
documentation => 'Prints this usage information.',
);
'Unknown option: q
'
];
+ # FIXME - it looks like we have a spacing issue in Getopt::Long?
my $exp = [
'Unknown option: q
',
- qq{usage: 104_override_usage.t [-?] [long options...]
-\t-? --usage --help Prints this usage information.
-\t--foo A foo
+ qq{usage: 104_override_usage.t [-?h] [long options...]
+\t-h -? --usage --help Prints this usage information.
+\t--foo A foo
}
];
# Update: since 0.41, usage info is printed to stdout, not stderr.
use strict; use warnings;
-use Test::More tests => 18;
+use Test::More tests => 22;
use Test::Trap;
{
isa_ok($obj->usage, 'Getopt::Long::Descriptive::Usage');
my $usage_text = $obj->usage->text;
-foreach my $args ( ['--help'], ['--usage'], ['--?'], ['-?'] )
+foreach my $args ( ['--help'], ['--usage'], ['--?'], ['-?'], ['-h'] )
{
local @ARGV = @$args;
note "Setting \@ARGV to @$args";
my $obj = MyClass->new_with_options();
my $expected = <<"USAGE";
-usage: 110_sort_usage_by_attr_order.t [-?] [long options...]
-\t-? --usage --help Prints this usage information.
-\t--foo Documentation for "foo"
-\t--bar Documentation for "bar"
-\t--baz Documentation for "baz"
+usage: 110_sort_usage_by_attr_order.t [-?h] [long options...]
+\t-h -? --usage --help Prints this usage information.
+\t--foo Documentation for "foo"
+\t--bar Documentation for "bar"
+\t--baz Documentation for "baz"
USAGE
is($obj->usage->text, $expected, 'Usage text has nicely sorted options');