Skip Menu |

This queue is for tickets about the MooseX-Getopt CPAN distribution.

Report information
The Basics
Id: 47766
Status: resolved
Priority: 0/
Queue: MooseX-Getopt

People
Owner: Nobody in particular
Requestors: DOY [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.20
Fixed in: (no value)



Subject: better integration with mx-simpleconfig
If the configfile attribute doesn't have a default, then mx-getopt skips over it if it's not specified on the command line, and just does its own thing, but if a default is specified, mx-simpleconfig will die if that default config file isn't present. I've attached a patch that will catch that exception and ignore it, but not sure if there's a better place for this, or a better way to implement it... thoughts?
Subject: simpleconfig.patch
diff --git a/lib/MooseX/Getopt.pm b/lib/MooseX/Getopt.pm index 41bedd3..31731ba 100644 --- a/lib/MooseX/Getopt.pm +++ b/lib/MooseX/Getopt.pm @@ -31,9 +31,16 @@ sub new_with_options { if(!defined $configfile) { my $cfmeta = $class->meta->find_attribute_by_name('configfile'); $configfile = $cfmeta->default if $cfmeta->has_default; + if (defined $configfile) { + $config_from_file = eval { + $class->get_config_from_file($configfile); + }; + if ($@) { + die $@ unless $@ =~ /Specified configfile '\Q$configfile\E' does not exist/; + } + } } - - if(defined $configfile) { + else { $config_from_file = $class->get_config_from_file($configfile); } }
Applied as 2c379a5, new release to follow shortly..