Subject: | usage not customizable for errors |
The current implementation details seem to provide an interesting qurik:
if you run a command, and the command lacks a required attribute, the "help/usage" error is displayed.
However, unlike "command --help", there is no way to change the displayed error in anyway, as the defined way of tweaking the error is never called.
In the attached example, 'example.pl' bails with a general GLD error, and 'example.pl -h' *also* fail with a general GLD error. ( -a is required, even to display help! )
The only way to trigger the modified usage is 'example.pl -a foo -h'
Incidentally, I've even tried wrapping the private method '_getopt_get_options', ( where the stack trace showed the error was triggered ), but that also proved useless, as the actual point of failure is within Getopt::Long space,
https://metacpan.org/source/ETHER/MooseX-Getopt-0.55/lib/MooseX/Getopt/GLD.pm#L52
And upon discovering that, I somewhat got lost and decided to file a bug so somebody who knows what they're doing could sort it out =)
usage: example.pl [-?ah] [long options...]
-h -? --usage --help Prints this usage information.
-a --attribute
at /home/kent/perl5/perlbrew/perls/perl-blead/lib/site_perl/5.17.9/Getopt/Long/Descriptive/Usage.pm line 101.
Getopt::Long::Descriptive::Usage::die('Getopt::Long::Descriptive::Usage=HASH(0x225e0e8)', 'HASH(0x23a36a8)') called at /home/kent/perl5/perlbrew/perls/perl-blead/lib/site_perl/5.17.9/Getopt/Long/Descriptive.pm line 281
Getopt::Long::Descriptive::_validate_with('name', 'attribute', 'params', 'HASH(0x23a02f8)', 'spec', 'HASH(0x23971f8)', 'opts', 'ARRAY(0x23a2d30)', 'usage', ...) called at /home/kent/perl5/perlbrew/perls/perl-blead/lib/site_perl/5.17.9/Getopt/Long/Descriptive.pm line 194
Getopt::Long::Descriptive::__ANON__('usage: %c %o', 'ARRAY(0x23933b0)', 'ARRAY(0x2397ac8)') called at /home/kent/perl5/perlbrew/perls/perl-blead/lib/site_perl/5.17.9/Getopt/Long/Descriptive.pm line 81
Getopt::Long::Descriptive::describe_options('usage: %c %o', 'ARRAY(0x23933b0)', 'ARRAY(0x2397ac8)', 'HASH(0x2397ee8)') called at /home/kent/perl5/perlbrew/perls/perl-blead/lib/site_perl/5.17.9/MooseX/Getopt/GLD.pm line 52
Class::MOP::Class:::around('CODE(0x232d930)', 'Example', 'HASH(0x2301e78)', 'ARRAY(0x224e330)') called at /home/kent/perl5/perlbrew/perls/perl-blead/lib/site_perl/5.17.9/x86_64-linux/Class/MOP/Method/Wrapped.pm line 162
Class::MOP::Method::Wrapped::__ANON__('Example', 'HASH(0x2301e78)', 'ARRAY(0x224e330)') called at /home/kent/perl5/perlbrew/perls/perl-blead/lib/site_perl/5.17.9/x86_64-linux/Class/MOP/Method/Wrapped.pm line 91
Example::_getopt_get_options('Example', 'HASH(0x2301e78)', 'ARRAY(0x224e330)') called at /home/kent/perl5/perlbrew/perls/perl-blead/lib/site_perl/5.17.9/MooseX/Getopt/Basic.pm line 132
MooseX::Getopt::Basic::__ANON__() called at /home/kent/perl5/perlbrew/perls/perl-blead/lib/site_perl/5.17.9/Try/Tiny.pm line 71
eval {...} called at /home/kent/perl5/perlbrew/perls/perl-blead/lib/site_perl/5.17.9/Try/Tiny.pm line 67
Try::Tiny::try('CODE(0x239f830)', 'Try::Tiny::Catch=REF(0x239fda0)') called at /home/kent/perl5/perlbrew/perls/perl-blead/lib/site_perl/5.17.9/MooseX/Getopt/Basic.pm line 136
MooseX::Getopt::Basic::_parse_argv('Example', 'options', 'ARRAY(0x2363f30)', 'params', 'HASH(0x2392d38)') called at /home/kent/perl5/perlbrew/perls/perl-blead/lib/site_perl/5.17.9/MooseX/Getopt/Basic.pm line 79
MooseX::Getopt::Basic::process_argv('Example') called at /home/kent/perl5/perlbrew/perls/perl-blead/lib/site_perl/5.17.9/MooseX/Getopt/Basic.pm line 105
MooseX::Getopt::Basic::new_with_options('Example') called at /home/kent/perl5/perlbrew/perls/perl-blead/lib/site_perl/5.17.9/MooseX/Getopt/Basic.pm line 168.
MooseX::Getopt::Basic::_getopt_spec_exception('Example', 'ARRAY(0x231d340)', 'Mandatory parameter \'attribute\' missing in call to (eval)\x{a}\x{a}...') called at /home/kent/perl5/perlbrew/perls/perl-blead/lib/site_perl/5.17.9/MooseX/Getopt/Basic.pm line 135
MooseX::Getopt::Basic::__ANON__('Mandatory parameter \'attribute\' missing in call to (eval)\x{a}\x{a}...') called at /home/kent/perl5/perlbrew/perls/perl-blead/lib/site_perl/5.17.9/Try/Tiny.pm line 100
Try::Tiny::try('CODE(0x239f830)', 'Try::Tiny::Catch=REF(0x239fda0)') called at /home/kent/perl5/perlbrew/perls/perl-blead/lib/site_perl/5.17.9/MooseX/Getopt/Basic.pm line 136
MooseX::Getopt::Basic::_parse_argv('Example', 'options', 'ARRAY(0x2363f30)', 'params', 'HASH(0x2392d38)') called at /home/kent/perl5/perlbrew/perls/perl-blead/lib/site_perl/5.17.9/MooseX/Getopt/Basic.pm line 79
MooseX::Getopt::Basic::process_argv('Example') called at /home/kent/perl5/perlbrew/perls/perl-blead/lib/site_perl/5.17.9/MooseX/Getopt/Basic.pm line 105
MooseX::Getopt::Basic::new_with_options('Example') called at example.pl line 29
Subject: | example.pl |