Skip Menu |

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

Report information
The Basics
Id: 40355
Status: rejected
Priority: 0/
Queue: Getopt-Long

People
Owner: Nobody in particular
Requestors: railpurdue [...] alumni.purdue.edu
Cc:
AdminCc:

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



Subject: not a bug but a request
Date: Fri, 24 Oct 2008 15:26:00 -0400
To: bug-Getopt-Long [...] rt.cpan.org
From: "Rail Shafigulin" <cybodrive [...] gmail.com>
This is not a bug report but a feature request. It would be really nice to have the ability to specify the values options can take. For example: Say I have an option -ext. I need this option be able to take on the following values only: txt, doc, xls, mp3, mp, wav. So if the user enters -ext vhdl then there will be an error saying that this option value is invalid. I currently have a way arround it but it would be really helpful to have that feature built-in Thank you
This is planned for some future version (but don't hold your breath). It is currently easy to do it with a callback function.
On Fri Oct 24 15:26:27 2008, railpurdue@alumni.purdue.edu wrote: Show quoted text
> For example: > Say I have an option -ext. I need this option be able to take on the > following values only: txt, doc, xls, mp3, mp, wav. So if the user enters > -ext vhdl then there will be an error saying that this option value is > invalid.
If wish mode is on, how about support for a regex: GetOptions( 'ext=/^(txt|doc|xls|mp3|mp|wav)$/' => \$extension ); ? Mike
On Mon Nov 24 11:37:44 2008, MOREGAN wrote: Show quoted text
> GetOptions( 'ext=/^(txt|doc|xls|mp3|mp|wav)$/' => \$extension );
GetOptions ( 'ext=s' => sub { my ($opt, $val) = @_; die("Invalid value $val for option $opt") unless $val =~ /^(txt|doc|xls|mp3|mp|wav)$/; $extension = $val; } );