From: Karen Etheridge Date: Thu, 30 Aug 2012 21:59:27 +0000 (-0700) Subject: also treat "-h" as a request for help X-Git-Tag: v0.46~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8d396d8a86e6c43b6722273362cab18b0fa622fc;p=gitmo%2FMooseX-Getopt.git also treat "-h" as a request for help --- diff --git a/Changes b/Changes index 85c2305..7dc7dfb 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ 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 diff --git a/lib/MooseX/Getopt.pm b/lib/MooseX/Getopt.pm index f8bd879..729ddb1 100644 --- a/lib/MooseX/Getopt.pm +++ b/lib/MooseX/Getopt.pm @@ -202,6 +202,7 @@ B option for each attribute to document. -? --? + -h --help --usage diff --git a/lib/MooseX/Getopt/GLD.pm b/lib/MooseX/Getopt/GLD.pm index d5a49de..2f74f95 100644 --- a/lib/MooseX/Getopt/GLD.pm +++ b/lib/MooseX/Getopt/GLD.pm @@ -22,12 +22,12 @@ role { 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.', ); diff --git a/t/104_override_usage.t b/t/104_override_usage.t index 8e7a1ff..be68178 100644 --- a/t/104_override_usage.t +++ b/t/104_override_usage.t @@ -42,12 +42,13 @@ use Test::Trap; '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 } ]; diff --git a/t/109_help_flag.t b/t/109_help_flag.t index eb75961..b5a0833 100644 --- a/t/109_help_flag.t +++ b/t/109_help_flag.t @@ -19,7 +19,7 @@ # 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; { @@ -42,7 +42,7 @@ ok($obj->meta->has_attribute('usage'), 'class has usage attribute'); 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"; diff --git a/t/110_sort_usage_by_attr_order.t b/t/110_sort_usage_by_attr_order.t index bddaffa..c7677e0 100644 --- a/t/110_sort_usage_by_attr_order.t +++ b/t/110_sort_usage_by_attr_order.t @@ -27,11 +27,11 @@ use Test::More tests => 1; 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');