Subject: | Feature suggestion: allow configuration of Getopt::Long |
I went searching for a way to disable bailing out if an unrecognized
error was passed, e.g:
perl -MMyApp::Foo -wle'my $obj = MyApp::Foo->new_with_options' --
--unrecognized_option
The feature in Getopt::Long that is relevant is "pass_through":
http://search.cpan.org/dist/Getopt-Long/lib/Getopt/Long.pm#Configuring_Getopt::Long
I found that simply adding this at the top of my class definition
(before applying MooseX::Getopt) works:
use Getopt::Long qw(:config pass_through);
However, that would override any other options and version checking that
the MX modules are performing. There is an alternate way of configuring
Getopt::Long:
Getopt::Long::Configure(qw(pass_through));
...which would need to be called in MooseX::Getopt::Basic
new_with_options() before instantiating the GO:L:Parser object. My
proposal is allowing these config options as role parameters to
MooseX::Getopt, e.g.:
with 'MooseX::Getopt' => { getopt_options => [ qw(pass_through) ] };
Alternatively, the class could provide a function which is invoked
inside new_with_options, which calls Getopt::Long::Configure, although I
don't think it's good a method:
sub new_with_options
{
...
$class->_configure_hook if $class->can('_configure_hook');
my $opt_parser = Getopt::Long::Parser->new(...);
...
}