Skip Menu |

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

Report information
The Basics
Id: 3115
Status: resolved
Worked: 1 min
Priority: 0/
Queue: Getopt-Auto

People
Owner: ARISTOTLE [...] cpan.org
Requestors: belkajm-cpan [...] aardvark-ss.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 1.00
Fixed in: 1.9.7



Subject: changes for consideration
The attached patch includes two changes to the module i would find useful. In reverse order: 1) Moves the code that is run for an unrecognized option out into its own subroutine. This allows me to override the default action with something else 2) Provides for further processing of the command line after the appropriate code has been run for an option, by not exiting the loop if a true value is returned from the option code. this allows for chaining of commands eg program command1 option1 option2 command2 command3 option1 where the options are processed by the code provided for each command Jody Belka
--- Auto.pm 2003-01-03 15:27:48.000000000 +0000 +++ Auto.pm.new 2003-08-01 18:26:28.000000000 +0100 @@ -137,8 +137,7 @@ if (grep { /^--version|-V$/ } @ARGV) { version(); exit 0; } while (my $foo = shift @ARGV) { if (exists $options{$foo}) { - $options{$foo}{code}->(@ARGV); - exit; + exit if !$options{$foo}{code}->(@ARGV); } else { if (_type($foo) ne $type and _type($foo) ne "bare") { if (_type($foo) eq "short") { @@ -150,14 +149,20 @@ } } else { # Don't know this. - print STDERR "Unrecognised option $foo\n"; - helpme(); + unrecognized($foo); } } } if (exists &main::default) { main::default() } } +sub unrecognized { + my $command = shift; + + print STDERR "Unrecognised option $command\n"; + helpme(); +} + package Getopt::Auto::PodExtract; use base 'Pod::Parser';
From: itegebo [...] berkeley.edu
On Fri Aug 01 13:43:24 2003, guest wrote: Show quoted text
> The attached patch includes two changes to the module i would find > useful. In reverse order: > > 1) Moves the code that is run for an unrecognized option out into its > own subroutine. This allows me to override the default action with > something else > > 2) Provides for further processing of the command line after the > appropriate code has been run for an option, by not exiting the > loop if a true value is returned from the option code. this allows > for chaining of commands > > eg program command1 option1 option2 command2 command3 option1 > > where the options are processed by the code provided for each command > > > Jody Belka
I also like these changes and am glad you've submitted them. I'll be testing this shortly.
RT-Send-CC: itegebo [...] berkeley.edu
Version 1.9.0 is a re-write of 1.0. I believe that it should satisfy your suggestions (for which, thanks).