X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMooseX-Getopt.git;a=blobdiff_plain;f=lib%2FMooseX%2FGetopt.pm;h=0c16a20154114a6309e89e6499eb173c219a9640;hp=2602a4a9fcd062c8e089e5a812b90ef4d019fefc;hb=ee69c4ba080aacb8eaa084320e9f96bb1ab40c9f;hpb=29e4cc39c46b48f421aa83d68d65566d4d579a84 diff --git a/lib/MooseX/Getopt.pm b/lib/MooseX/Getopt.pm index 2602a4a..0c16a20 100644 --- a/lib/MooseX/Getopt.pm +++ b/lib/MooseX/Getopt.pm @@ -23,11 +23,21 @@ sub new_with_options { ] ); + my $params = $processed{params}; + + if($class->meta->does_role('MooseX::ConfigFromFile') + && defined $params->{configfile}) { + %$params = ( + %{$class->get_config_from_file($params->{configfile})}, + %$params, + ); + } + $class->new( ARGV => $processed{argv_copy}, extra_argv => $processed{argv}, @params, # explicit params to ->new - %{ $processed{params} }, # params from CLI + %$params, # params from CLI ); } @@ -179,6 +189,11 @@ to have the leading underscore in thier name, you can do this: This will mean that Getopt will not handle a --foo param, but your code can still call the C method. +If your class also uses a configfile-loading role based on +L, such as L, +L's C will load the configfile +specified by the C<--configfile> option for you. + =head2 Supported Type Constraints =over 4