From: Piotr Roszatycki Date: Thu, 27 Nov 2008 14:52:07 +0000 (+0000) Subject: * MooseX::Getopt::Parser::Descriptive: Getopt::Long::Descriptive::Usage object X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e013a17c4eaa4b6e075aa25ea316892c4b96bb34;p=gitmo%2FMooseX-Getopt.git * MooseX::Getopt::Parser::Descriptive: Getopt::Long::Descriptive::Usage object is available via MooseX::Getopt::Session->parser->usage rather than passed via new_with_options( usage => $usage ) constructor. --- diff --git a/ChangeLog b/ChangeLog index 39d85bf..488f283 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,6 +20,11 @@ Revision history for Perl extension MooseX-Getopt - Getopt parser is pluggined. (dexter) + * MooseX::Getopt::Parser::Descriptive + - Getopt::Long::Descriptive::Usage object is available via + MooseX::Getopt::Session->parser->usage rather than passed via + new_with_options( usage => $usage ) constructor. (dexter) + 0.15 Sat. July 26 2008 * MooseX::Getopt::OptionTypeMap - Accept type constraint objects in the type mapping, not just names diff --git a/lib/MooseX/Getopt/Parser/Descriptive.pm b/lib/MooseX/Getopt/Parser/Descriptive.pm index ff05c8f..bc4bf57 100644 --- a/lib/MooseX/Getopt/Parser/Descriptive.pm +++ b/lib/MooseX/Getopt/Parser/Descriptive.pm @@ -25,6 +25,13 @@ has format => ( default => 'usage: %c %o', ); +# Usage object +has usage => ( + is => 'rw', + isa => 'Maybe[Getopt::Long::Descriptive::Usage]', + predicate => 'has_usage', +); + sub build_options { my $self = shift; @@ -89,11 +96,14 @@ sub build_options { $getopt->extra_argv( $extra_argv ); }; + # Store usage object + $self->usage( $usage ); + # Convert cmd_flags back to names in options hashref $new_options = { map { $cmd_flags_to_names{$_} => $new_options->{$_} } keys %$new_options }; - # Include old options and usage object - $new_options = { usage => $usage, %$options, %$new_options }; + # Include old options + $new_options = { %$options, %$new_options }; $getopt->status( ! $warnings ); $getopt->options( $new_options );