- Getopt parser is pluggined.
(dexter)
- * TODO:
- - MooseX::ConfigFromFile should be restored?
-
0.15 Sat. July 26 2008
* MooseX::Getopt::OptionTypeMap
- Accept type constraint objects in the type mapping, not just names
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] } : @_ );
+ my %params = ( $class->_get_options_from_configfile, @_ == 1 ? %{ $_[0] } : @_ );
my $getopt = defined $params{getopt}
? $params{getopt}
};
+sub _get_options_from_configfile {
+ my $class = shift;
+
+ my %params = ();
+
+ if ($class->meta->does_role('MooseX::ConfigFromFile')) {
+ local @ARGV = @ARGV;
+
+ my $configfile;
+ my $opt_parser = Getopt::Long::Parser->new( config => [ 'pass_through' ] );
+ $opt_parser->getoptions( "configfile=s" => \$configfile );
+
+ if (not defined $configfile) {
+ my $cfmeta = $class->meta->find_attribute_by_name('configfile');
+ $configfile = $cfmeta->default if $cfmeta->has_default;
+ };
+
+ if (defined $configfile) {
+ %params = %{ $class->get_config_from_file($configfile) };
+ };
+ };
+
+ return %params;
+};
+
+
sub _compute_getopt_attrs {
my $class = shift;