Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the App-Cmd CPAN distribution.

Report information
The Basics
Id: 35507
Status: resolved
Priority: 0/
Queue: App-Cmd

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

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: Getopt::Long package var 'pass_through'
Hi Ricardo, thanks a lot for App::Cmd and the rest of your wonderful modules, especially Sub::Exporter! I tried your App::Cmd framework for a CLI used with Net::SNMP::Mixin. I found the following nasty problem: During global option processing the Getopt::Long config parameter 'pass_through' is set, in order to leave the rest of the @ARGV intact. But successive command option processing is still tangled by these Getopt::Long package variable and wrong command options are not detected. That's a problem, because this isn't described and is against the default behavior of Getopt::Long. There should be a reset of this Getopt::Long package variable(s) to default behavior. I think, this should best be done in App::Cmd::ArgProcessor::__process_args. See my attached patch. Best regards Charly
Subject: ArgProcessor.pm.patch
--- lib/App/Cmd/ArgProcessor.pm 2008-03-20 02:59:21.000000000 +0100 +++ /tmp/ArgProcessor.pm 2008-04-29 10:18:04.000000000 +0200 @@ -23,6 +23,10 @@ my ($opt, $usage) = Getopt::Long::Descriptive::describe_options(@params); + # patch by charly -- 29.4.2008 + # reset Getopt::Long to default behavior for successive calls + Getopt::Long::Configure('default'); + return ( $opt, [ @ARGV ], # whatever remained
Il Mar 29 Apr 2008 04:22:55, GAISSMAI ha scritto: Show quoted text
> During global option processing the Getopt::Long config parameter > 'pass_through' is set, in order to leave the rest of the @ARGV intact. > > But successive command option processing is still tangled by these > Getopt::Long package variable and wrong command options are not > detected.
I found that this can be worked around without a patch, even though I think your patch would be useful or at least this behaviour should be documented properly. Here's how I write opt_spec for applying the default stuff and force my gnu_getopt preferred style: sub opt_spec { my $self = shift; return ( ['foo' => 'some option'], ['bar' => 'some other option'], # ... all other options as anonymous arrays, then as the last item: { getopt_conf => [qw( default gnu_getopt )] }, ); }
Am Sa 22. Mai 2010, 09:58:39, POLETTIX schrieb: Show quoted text
> Il Mar 29 Apr 2008 04:22:55, GAISSMAI ha scritto:
> > During global option processing the Getopt::Long config parameter > > 'pass_through' is set, in order to leave the rest of the @ARGV
> intact.
> > > > But successive command option processing is still tangled by these > > Getopt::Long package variable and wrong command options are not > > detected.
> > I found that this can be worked around without a patch, even though I > think your patch > would be useful or at least this behaviour should be documented > properly. > > Here's how I write opt_spec for applying the default stuff and force > my gnu_getopt preferred > style: > > sub opt_spec { > my $self = shift; > return ( > ['foo' => 'some option'], > ['bar' => 'some other option'], > # ... all other options as anonymous arrays, then as the last > item: > { getopt_conf => [qw( default gnu_getopt )] }, > ); > }
sounds good best regards Charly