- Use Moose's throw_error() method. (dexter)
* MooseX::Getopt
+ - New method get_options_from_argv. (dexter)
+
+ * MooseX::Getopt
* MooseX::Getopt::Session
- MooseX::Getopt can start new Getopt session or get it as parameter
(dexter)
sub new_with_options {
my $class = shift;
- Moose->throw_error("Single parameters to new_with_options() must be a HASH ref")
+ return $class->new( $class->get_options_from_argv(@_) );
+};
+
+
+sub get_options_from_argv {
+ my $class = shift;
+
+ Moose->throw_error("Single parameters to get_options_from_argv() must be a HASH ref")
if ref $_[0] and ref $_ ne 'HASH';
my %params = ( @_ == 1 ? %{ $_[0] } : @_ );
params => \%params,
);
- $class->new(
- getopt => $getopt,
+ my %new_params = (
%{ $getopt->params }, # params from session object
%params, # explicit params to ->new
%{ $getopt->options }, # params from CLI
+ getopt => $getopt,
);
+
+ return %new_params;
};
If you have L<Getopt::Long::Descriptive> a the C<usage> param is also passed to
C<new>.
+=item B<get_options_from_argv (%params)>
+
+This method returns the list of parameters collected from command line
+without creating the new object.
+
=item B<ARGV>
This accessor contains a reference to a copy of the C<@ARGV> array as it