X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FGetopt.pm;fp=lib%2FMooseX%2FGetopt.pm;h=0e4a2687eb5ac1ecfb30f342443da3edc06db200;hb=10ed52cb080cfbe757fdb2a4c7ceb463fba93e6c;hp=27c17c8496eefd2e71629aa0d9969a12d20619af;hpb=d09046450c54b37640fed28a06a17b7d040ba81a;p=gitmo%2FMooseX-Getopt.git diff --git a/lib/MooseX/Getopt.pm b/lib/MooseX/Getopt.pm index 27c17c8..0e4a268 100644 --- a/lib/MooseX/Getopt.pm +++ b/lib/MooseX/Getopt.pm @@ -40,30 +40,29 @@ sub get_options_from_argv { Moose->throw_error("Single parameters to get_options_from_argv() must be a HASH ref") if ref $_[0] and ref $_ ne 'HASH'; - my %params = ( $class->_get_options_from_configfile, @_ == 1 ? %{ $_[0] } : @_ ); + my $options = { %{ $class->get_options_from_configfile }, @_ == 1 ? %{ $_[0] } : @_ }; - my $getopt = defined $params{getopt} - ? $params{getopt} + my $getopt = defined $options->{getopt} + ? $options->{getopt} : $class->_default_getopt_session->new( classes_filter => sub { $_ eq $class }, - params => \%params, + options => $options, ); - my %new_params = ( - %{ $getopt->params }, # params from session object - %params, # explicit params to ->new - %{ $getopt->options }, # params from CLI + my $new_options = { + %{ $options }, # explicit options to ->new + %{ $getopt->options }, # options from CLI getopt => $getopt, - ); + }; - return %new_params; + return $new_options; }; -sub _get_options_from_configfile { +sub get_options_from_configfile { my $class = shift; - my %params = (); + my $options = {}; if ($class->meta->does_role('MooseX::ConfigFromFile')) { local @ARGV = @ARGV; @@ -78,11 +77,11 @@ sub _get_options_from_configfile { }; if (defined $configfile) { - %params = %{ $class->get_config_from_file($configfile) }; + $options = $class->get_config_from_file($configfile); }; }; - return %params; + return $options; }; @@ -339,6 +338,11 @@ C. This method returns the list of parameters collected from command line without creating the new object. +=item B + +This method returns the list of parameters collected with +L mechanism. + =item B This accessor contains a reference to a copy of the C<@ARGV> array as it