NAME
Getopt::Long::Descriptive - Getopt::Long with usage text
VERSION
0.01
DESCRIPTION
Convenient wrapper for Getopt::Long and program usage output
SYNOPSIS
use Getopt::Long::Descriptive;
my ($opts, $usage) = describe_options($format, @opts, \%arg);
FORMAT
$format = "usage: myprog %o myarg...";
%o
will be replaced with a list of the short options, as well as the text "[long options...]" if any have been defined.
Because of this, any literal %
symbols will need to be written as %%
.
OPTIONS
Option specifications are the same as in Getopt::Long. You should pass in an array of arrayrefs whose first elements are option specs and whose second elements are descriptions.
my @opts = ([ "verbose|V" => "be noisy" ],
[ "logfile=s" => "file to log to" ]);
Option specifications may have a third hashref argument. If present, this configures extra restrictions on the value or presence of that option.
Option Constraints
implies
implies => 'bar'
implies => [qw(foo bar)]
implies => { foo => 1, bar => 2 }
required
Params::Validate
In addition, any constraint understood by Params::Validate may be used.
(Internally, all constraints are translated into Params::Validate options or callbacks.)
EXTRA ARGUMENTS
If the last parameter is a hashref, it contains extra arguments to modify the way describe_options
works. Valid arguments are:
getopt_conf - an arrayref of strings, passed to Getopt::Long::Configure
EXPORTED FUNCTIONS
describe_options
See SYNOPSIS; returns a hashref of option values and an object that represents the usage statement.
The usage statement has several methods:
$usage->text
returns the usage string$usage->warn
prints usage to STDERR$usage->die
dies with the usage string
:types
Any of the Params::Validate type constants (SCALAR
, etc.) can be imported as well. You can get all of them at once by importing :types
.
CONFIGURATION
$MungeOptions
When $Getopt::Long::Descriptive::MungeOptions
is true, some munging is done to make option names more hash-key friendly:
All keys are lowercased
-
is changed to_
The default is a true value.
SEE ALSO
AUTHOR
Hans Dieter Pearcey, <hdp@cpan.org>
BUGS
Please report any bugs or feature requests to bug-getopt-long-descriptive@rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Getopt-Long-Descriptive. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
COPYRIGHT & LICENSE
Copyright 2005 Hans Dieter Pearcey, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.