getopt expar
Sponsored Links
Sponsored Links
Secleted [ 0 ] software to compare
Results 1 - 15 of about 65
Getopt::ExPar 0.01
Getopt::ExPar contains extended parameters command line parser. more>>
Getopt::ExPar contains extended parameters command line parser.
SYNOPSIS
use Getopt::ExPar;
my(@PDT, @MM, %OPT);
ExPar @PDT, @MM, $OPT;
EXPORT
use Getopt::ExPar exports the sub ExPar into your name space.
ExPar is a perl5 module used to parse command line parameters. This package uses the @PDT, Parameter Description Table, and the @MM, Message Module, to return %OPT which is a hash reference containing the command line option data. The function of Getopt::ExPar is based on Getopt::EvaP, created by Stephen O. Lidie.
Introduction
The ExPar function parses a perl command line. Using the option definitions in the @PDT, argument types are checked and the arguments themselves may be checked against a specified range or pattern. By using both @PDT and @MM, several types of help may be retured to the user. ExPar handles command lines with this format:
command [-parameters] [file_list]
where any parameters and file_list are optional.
Parameter Description Table (PDT) Syntax
Here is the PDT syntax. Optional constructs are enclosed in [], and the | character separates possible values in a list.
PDT [program_name, alias]
[parameter_name[, alias]: type [pattern | range] [ = [default_variable,] default_value]]
PDTEND [flag_list]
flag_list is one or more of the following flags: optional_file_list | required_file_list | no_file_list: specifies condition of list of files at end of command line. (only one of these may be specified) abbreviations: allows for abbreviations of commands or aliases as long as enough of the command is given to make it distinguishable from all others. If not, a message is printed so the user may be more specific. switchglomming: allows for multiple single-letter switch options to be specified as single option (must be first option). pdt_warnings: for debugging a @PDT, it prints out messages that are not necessarily errors, like inconsistent number of default values in a list, etc.
The default_variable is an environment variable - see the section Usage Notes for complete details.
So, the simplest possible PDT would be:
PDT
PDTEND
This PDT would simply define a -help switch for the command, but is rather useless.
A typical PDT would look more like this:
PDT frog
number, n: integer = 1
chars, c: string = "default_string"
PDTEND no_file_list
This PDT, for command frog, defines two parameters, number (or n), of type integer with a default value of 1, and chars (or c), of type string with a default value of "default_string". The PDTEND no_file_list indicator indicates that no trailing file_list can appear on the command line. Of course, the -help switch is defined automatically.
Each of these options may be further refined by using a range and a pattern, respectively:
PDT frog
number, n: integer (((#100, the # is implied. Other simple conditions are < and == (a single = is accepted as ==, not an assignment). Ex: This condition: (#>10, #<<less
SYNOPSIS
use Getopt::ExPar;
my(@PDT, @MM, %OPT);
ExPar @PDT, @MM, $OPT;
EXPORT
use Getopt::ExPar exports the sub ExPar into your name space.
ExPar is a perl5 module used to parse command line parameters. This package uses the @PDT, Parameter Description Table, and the @MM, Message Module, to return %OPT which is a hash reference containing the command line option data. The function of Getopt::ExPar is based on Getopt::EvaP, created by Stephen O. Lidie.
Introduction
The ExPar function parses a perl command line. Using the option definitions in the @PDT, argument types are checked and the arguments themselves may be checked against a specified range or pattern. By using both @PDT and @MM, several types of help may be retured to the user. ExPar handles command lines with this format:
command [-parameters] [file_list]
where any parameters and file_list are optional.
Parameter Description Table (PDT) Syntax
Here is the PDT syntax. Optional constructs are enclosed in [], and the | character separates possible values in a list.
PDT [program_name, alias]
[parameter_name[, alias]: type [pattern | range] [ = [default_variable,] default_value]]
PDTEND [flag_list]
flag_list is one or more of the following flags: optional_file_list | required_file_list | no_file_list: specifies condition of list of files at end of command line. (only one of these may be specified) abbreviations: allows for abbreviations of commands or aliases as long as enough of the command is given to make it distinguishable from all others. If not, a message is printed so the user may be more specific. switchglomming: allows for multiple single-letter switch options to be specified as single option (must be first option). pdt_warnings: for debugging a @PDT, it prints out messages that are not necessarily errors, like inconsistent number of default values in a list, etc.
The default_variable is an environment variable - see the section Usage Notes for complete details.
So, the simplest possible PDT would be:
PDT
PDTEND
This PDT would simply define a -help switch for the command, but is rather useless.
A typical PDT would look more like this:
PDT frog
number, n: integer = 1
chars, c: string = "default_string"
PDTEND no_file_list
This PDT, for command frog, defines two parameters, number (or n), of type integer with a default value of 1, and chars (or c), of type string with a default value of "default_string". The PDTEND no_file_list indicator indicates that no trailing file_list can appear on the command line. Of course, the -help switch is defined automatically.
Each of these options may be further refined by using a range and a pattern, respectively:
PDT frog
number, n: integer (((#100, the # is implied. Other simple conditions are < and == (a single = is accepted as ==, not an assignment). Ex: This condition: (#>10, #<<less
Download (0.018MB)
Added: 2007-08-07 License: Perl Artistic License Price:
808 downloads
Getopt::Declare 1.11
Getopt::Declare is a Perl module with Declaratively Expressed Command-Line Arguments via Regular Expressions. more>>
Getopt::Declare is a Perl module with Declaratively Expressed Command-Line Arguments via Regular Expressions.
SYNOPSIS
use Getopt::Declare;
$args = Getopt::Declare->new($specification_string, $optional_source);
# or:
use Getopt::Declare $specification_string => $args;
Getopt::Declare is yet another command-line argument parser, one which is specifically designed to be powerful but exceptionally easy to use.
To parse the command-line in @ARGV, one simply creates a Getopt::Declare object, by passing Getopt::Declare::new() a specification of the various parameters that may be encountered:
use Getopt::Declare;
$args = Getopt::Declare->new($specification);
This may also be done in a one-liner:
use Getopt::Declare, $specification => $args;
The specification is a single string such as this:
$specification = q(
-a Process all data
-b < N:n > Set mean byte length threshold to
{ bytelen = $N; }
+c < FILE > Create new file
--del Delete old file
{ delold() }
delete [ditto]
e < H:i >x< W:i > Expand image to height < H > and width < W >
{ expand($H,$W); }
-F < file >... Process named file(s)
{ defer {for (@file) {process()}} }
=getrand [< N >] Get a random number
(or, optionally, < N > of them)
{ $N = 1 unless defined $N; }
-- Traditionally indicates end of arguments
{ finish }
<<lessSYNOPSIS
use Getopt::Declare;
$args = Getopt::Declare->new($specification_string, $optional_source);
# or:
use Getopt::Declare $specification_string => $args;
Getopt::Declare is yet another command-line argument parser, one which is specifically designed to be powerful but exceptionally easy to use.
To parse the command-line in @ARGV, one simply creates a Getopt::Declare object, by passing Getopt::Declare::new() a specification of the various parameters that may be encountered:
use Getopt::Declare;
$args = Getopt::Declare->new($specification);
This may also be done in a one-liner:
use Getopt::Declare, $specification => $args;
The specification is a single string such as this:
$specification = q(
-a Process all data
-b < N:n > Set mean byte length threshold to
{ bytelen = $N; }
+c < FILE > Create new file
--del Delete old file
{ delold() }
delete [ditto]
e < H:i >x< W:i > Expand image to height < H > and width < W >
{ expand($H,$W); }
-F < file >... Process named file(s)
{ defer {for (@file) {process()}} }
=getrand [< N >] Get a random number
(or, optionally, < N > of them)
{ $N = 1 unless defined $N; }
-- Traditionally indicates end of arguments
{ finish }
Download (0.035MB)
Added: 2006-11-03 License: Perl Artistic License Price:
1085 downloads
Getopt::GetArgs 1.03
GetArgs is a Perl module to allow enhanced argument passing. more>>
GetArgs is a Perl module to allow enhanced argument passing, including passing of case-insensitive named arguments as well as positioned arguments.
SYNOPSIS
sub WHATEVER {
my @DEFAULT_ARGS =
( Content => "Default content",
Verbose => 0
);
my %ARGS=GetArgs(@_,@DEFAULT_ARGS);
# do some stuff with $ARGS{Content}
# show all kinds of detail if $ARGS{Verbose}
}
# a simple call to WHATEVER
WHATEVER( "Just deal with my content" );
# a flexible call to WHATEVER
WHATEVER({ verbose => 1,
content => "This is my content",
});
GetArgs needs to know * what your subroutine was passed, * and what it expected to be passed. * If you like, you can also supply default values to use when an argument is not passed.
Using this information, GetArgs will create a hash of arguments for you to use throughout your subroutine. Using GetArgs has several advantages:
1) Calls to your subroutine can pass named arguments, making the code more readable.
2) If its easier to pass a list of arguments as you normally would, thats fine.
3) With GetArgs your use of arguments in your subroutine code is more readable.
4) Your subroutines are no longer limited in the number of arguments they expect.
5) Arguments can be passed in any order (if passed inside the hash ref), thus only the arguments relevant to that call need to be passed--unnecessary arguments can be ignored.
6) Case is not important, as GetArgs matches argument names case insensitively.
<<lessSYNOPSIS
sub WHATEVER {
my @DEFAULT_ARGS =
( Content => "Default content",
Verbose => 0
);
my %ARGS=GetArgs(@_,@DEFAULT_ARGS);
# do some stuff with $ARGS{Content}
# show all kinds of detail if $ARGS{Verbose}
}
# a simple call to WHATEVER
WHATEVER( "Just deal with my content" );
# a flexible call to WHATEVER
WHATEVER({ verbose => 1,
content => "This is my content",
});
GetArgs needs to know * what your subroutine was passed, * and what it expected to be passed. * If you like, you can also supply default values to use when an argument is not passed.
Using this information, GetArgs will create a hash of arguments for you to use throughout your subroutine. Using GetArgs has several advantages:
1) Calls to your subroutine can pass named arguments, making the code more readable.
2) If its easier to pass a list of arguments as you normally would, thats fine.
3) With GetArgs your use of arguments in your subroutine code is more readable.
4) Your subroutines are no longer limited in the number of arguments they expect.
5) Arguments can be passed in any order (if passed inside the hash ref), thus only the arguments relevant to that call need to be passed--unnecessary arguments can be ignored.
6) Case is not important, as GetArgs matches argument names case insensitively.
Download (0.004MB)
Added: 2007-04-11 License: Perl Artistic License Price:
926 downloads
Getopt::EvaP 2.3.5
Getopt::EvaP is a Perl module to evaluate Perl command line parameters. more>>
Getopt::EvaP is a Perl module to evaluate Perl command line parameters.
SYNOPSIS
use vars qw/@PDT @MM %OPT/;
use Getopt::EvaP;
EvaP @PDT, @MM, %OPT;
EXPORT
use Getopt::EvaP exports the subs EvaP and EvaP_PAC into your name space.
@PDT is the Parameter Description Table, which is a reference to a list of strings describing the command line parameters, aliases, types and default values. @MM is the Message Module, which is also a reference to a list of strings describing the command and its parameters. %OPT is an optional hash reference where Evaluate Parameters should place its results. If specified, the historical behaviour of modifying the calling routines namespace by storing option values in %Options, %options and $opt* is disabled.
<<lessSYNOPSIS
use vars qw/@PDT @MM %OPT/;
use Getopt::EvaP;
EvaP @PDT, @MM, %OPT;
EXPORT
use Getopt::EvaP exports the subs EvaP and EvaP_PAC into your name space.
@PDT is the Parameter Description Table, which is a reference to a list of strings describing the command line parameters, aliases, types and default values. @MM is the Message Module, which is also a reference to a list of strings describing the command and its parameters. %OPT is an optional hash reference where Evaluate Parameters should place its results. If specified, the historical behaviour of modifying the calling routines namespace by storing option values in %Options, %options and $opt* is disabled.
Download (0.051MB)
Added: 2006-11-02 License: Perl Artistic License Price:
1087 downloads
Tk::Getopt 0.49
Tk::Getopt is a user configuration window for Tk with interface to Getopt::Long. more>>
Tk::Getopt is a user configuration window for Tk with interface to Getopt::Long.
SYNOPSIS
use Tk::Getopt;
@opttable = ([opt1, =s, default], [opt2, !, 1], ...);
$opt = new Tk::Getopt(-opttable => @opttable,
-options => %options,
-filename => "$ENV{HOME}/.options");
$opt->set_defaults; # set default values
$opt->load_options; # configuration file
$opt->get_options; # command line
$opt->process_options; # process callbacks, check restrictions ...
print $options->{opt1}, $options->{opt2} ...;
...
$top = new MainWindow;
$opt->option_editor($top);
or using a Getopt::Long-like interface
$opt = new Tk::Getopt(-getopt => [help => $HELP,
file:s => $FILE,
foo! => $FOO,
num:i => $NO,
]);
or an alternative Getopt::Long interface
%optctl = (foo => $foo,
bar => $bar);
$opt = new Tk::Getopt(-getopt => [%optctl, "foo!", "bar=s"]);
Tk::Getopt provides an interface to access command line options via Getopt::Long and editing with a graphical user interface via a Tk window.
Unlike Getopt::Long, this package uses a object oriented interface, so you have to create a new Tk::Getopt object with new. Unlike other packages in the Tk hierarchy, this package does not define a Tk widget. The graphical interface is calles by the method option_editor.
After creating an object with new, you can parse command line options by calling get_options. This method calls itself Getopt::Long::GetOptions.
<<lessSYNOPSIS
use Tk::Getopt;
@opttable = ([opt1, =s, default], [opt2, !, 1], ...);
$opt = new Tk::Getopt(-opttable => @opttable,
-options => %options,
-filename => "$ENV{HOME}/.options");
$opt->set_defaults; # set default values
$opt->load_options; # configuration file
$opt->get_options; # command line
$opt->process_options; # process callbacks, check restrictions ...
print $options->{opt1}, $options->{opt2} ...;
...
$top = new MainWindow;
$opt->option_editor($top);
or using a Getopt::Long-like interface
$opt = new Tk::Getopt(-getopt => [help => $HELP,
file:s => $FILE,
foo! => $FOO,
num:i => $NO,
]);
or an alternative Getopt::Long interface
%optctl = (foo => $foo,
bar => $bar);
$opt = new Tk::Getopt(-getopt => [%optctl, "foo!", "bar=s"]);
Tk::Getopt provides an interface to access command line options via Getopt::Long and editing with a graphical user interface via a Tk window.
Unlike Getopt::Long, this package uses a object oriented interface, so you have to create a new Tk::Getopt object with new. Unlike other packages in the Tk hierarchy, this package does not define a Tk widget. The graphical interface is calles by the method option_editor.
After creating an object with new, you can parse command line options by calling get_options. This method calls itself Getopt::Long::GetOptions.
Download (0.022MB)
Added: 2006-11-03 License: Perl Artistic License Price:
1085 downloads
Getopt::OO 0.07
Getopt::OO is an object oriented command line parser. more>>
Getopt::OO is an object oriented command line parser. It handles short, long and multi (--x ... -) value options. Getopt::OO module also incorporates help for options to simplify generation of usage statements.
SYNOPSIS
use Getopt::OO qw(Debug Verbose);
my ($handle) = Getopt::OO->new(@ARGV,
-d => {
help => turn on debug output,
callback => sub {Debug(1); 0},
},
-o => {
help => another option.,
},
-f => {
help => option that expects one more value.,
n_values => 1,
},
--long {
help => long option
},
--multiple_ => {
help => [
"Everything between --multiple_values and - is",
"an value for this options",
],
multi_value => 1,
multiple= => 1, # Can happen more than once on command line.
},
other_values => {
help => file_1 ... file_n,
multi_value => 1,
},
);
if ($handle->Values()) {
Debug("You will get output if -d was on command line");
if (my $f = handle->Values(-f)) {
print "Got $f with the -f value.n";
}
}
else {
print "No options found on command line.n";
}
Getopt::OO is an object oriented tool for parsing command line arguments. It expects a reference to the input arguments and uses a perl hash to describe how the command line arguments should be parsed. Note that by parsed, we mean what options expect values, etc. We check to make sure values exist on the command line as necessary -- nothing else. The caller is responsible for making sure that a value that he knows should be a file exists, is writable, or whatever.
Command line arguments can be broken into two distinct types: options and values that are associated with these options. In windows, options often start with a / but sometimes with a -, but in unix they almost universally start with a -. For this module options start with a -. We support two types of options: the short single dashed options and the long double dashed options.
The difference between these two is that with this module the short options can be combined into a single option, but the long options can not. For example, most of us will be familiar with the tar -xvf file command which can also be expressed as -x -v -f file. Long options can not be combined this way, so --help for example must always stand by itself.
The input template expects the option names as its keys. For instance if you were expecting -xv --hello as possible command line options, the keys for your template hash would be -x, -v, and --hello.
<<lessSYNOPSIS
use Getopt::OO qw(Debug Verbose);
my ($handle) = Getopt::OO->new(@ARGV,
-d => {
help => turn on debug output,
callback => sub {Debug(1); 0},
},
-o => {
help => another option.,
},
-f => {
help => option that expects one more value.,
n_values => 1,
},
--long {
help => long option
},
--multiple_ => {
help => [
"Everything between --multiple_values and - is",
"an value for this options",
],
multi_value => 1,
multiple= => 1, # Can happen more than once on command line.
},
other_values => {
help => file_1 ... file_n,
multi_value => 1,
},
);
if ($handle->Values()) {
Debug("You will get output if -d was on command line");
if (my $f = handle->Values(-f)) {
print "Got $f with the -f value.n";
}
}
else {
print "No options found on command line.n";
}
Getopt::OO is an object oriented tool for parsing command line arguments. It expects a reference to the input arguments and uses a perl hash to describe how the command line arguments should be parsed. Note that by parsed, we mean what options expect values, etc. We check to make sure values exist on the command line as necessary -- nothing else. The caller is responsible for making sure that a value that he knows should be a file exists, is writable, or whatever.
Command line arguments can be broken into two distinct types: options and values that are associated with these options. In windows, options often start with a / but sometimes with a -, but in unix they almost universally start with a -. For this module options start with a -. We support two types of options: the short single dashed options and the long double dashed options.
The difference between these two is that with this module the short options can be combined into a single option, but the long options can not. For example, most of us will be familiar with the tar -xvf file command which can also be expressed as -x -v -f file. Long options can not be combined this way, so --help for example must always stand by itself.
The input template expects the option names as its keys. For instance if you were expecting -xv --hello as possible command line options, the keys for your template hash would be -x, -v, and --hello.
Download (0.019MB)
Added: 2006-10-28 License: Perl Artistic License Price:
1091 downloads
Getopt::Tabular 0.3
Getopt::Tabular is a Perl module for table-driven argument parsing for Perl 5. more>>
Getopt::Tabular is a Perl module for table-driven argument parsing for Perl 5.
SYNOPSIS
use Getopt::Tabular;
(or)
use Getopt::Tabular qw/GetOptions
SetHelp SetHelpOption
SetError GetError/;
...
≥topt::Tabular::SetHelp (long_help, usage_string);
@opt_table = (
[section_description, "section"],
[option, type, num_values, option_data, help_string],
...
);
≥tOptions (@opt_table, @ARGV [, @newARGV]) || exit 1;
Getopt::Tabular is a Perl 5 module for table-driven argument parsing, vaguely inspired by John Ousterhouts Tk_ParseArgv. All you really need to do to use the package is set up a table describing all your command-line options, and call ≥tOptions with three arguments: a reference to your option table, a reference to @ARGV (or something like it), and an optional third array reference (say, to @newARGV). ≥tOptions will process all arguments in @ARGV, and copy any leftover arguments (i.e. those that are not options or arguments to some option) to the @newARGV array. (If the @newARGV argument is not supplied, GetOptions will replace @ARGV with the stripped-down argument list.) If there are any invalid options, GetOptions will print an error message and return 0.
<<lessSYNOPSIS
use Getopt::Tabular;
(or)
use Getopt::Tabular qw/GetOptions
SetHelp SetHelpOption
SetError GetError/;
...
≥topt::Tabular::SetHelp (long_help, usage_string);
@opt_table = (
[section_description, "section"],
[option, type, num_values, option_data, help_string],
...
);
≥tOptions (@opt_table, @ARGV [, @newARGV]) || exit 1;
Getopt::Tabular is a Perl 5 module for table-driven argument parsing, vaguely inspired by John Ousterhouts Tk_ParseArgv. All you really need to do to use the package is set up a table describing all your command-line options, and call ≥tOptions with three arguments: a reference to your option table, a reference to @ARGV (or something like it), and an optional third array reference (say, to @newARGV). ≥tOptions will process all arguments in @ARGV, and copy any leftover arguments (i.e. those that are not options or arguments to some option) to the @newARGV array. (If the @newARGV argument is not supplied, GetOptions will replace @ARGV with the stripped-down argument list.) If there are any invalid options, GetOptions will print an error message and return 0.
Download (0.025MB)
Added: 2006-09-29 License: Perl Artistic License Price:
1120 downloads
Getopt::Helpful 0.04
Getopt::Helpful is an integrated option hash / help messages. more>>
Getopt::Helpful is an integrated option hash / help messages.
STATE
This module is still under development, but is being publish on CPAN to satisfy some code which depends on it. The interface may change in a future version and some of the functionality is not yet complete.
SYNOPSIS
This module provides methods which integrate help messages into a Getopt::Long option spec. This gathers documentation and declaration into one place and allows you to utilize perl code to state the default values of options in your online help messages (helping you utilize the single-point-of-truth principle.)
Additionally, it provides DWIM methods (Get) which allow you to cut some standard error-checking code from your scripts. There is even a handy usage() method which eliminates that silly block of code from the beginning.
#!/usr/bin/perl
use warnings;
use strict;
use Getopt::Helpful;
my $var1 = "default";
my $req_arg;
# declare this as our or $main::verbose
our $verbose = 0;
# every option must be passed into the constructor...
my $hopt = Getopt::Helpful->new(
usage => CALLER [options],
[
var=s, $default,
,
"setting for $var1 (default: $var1)"
],
[
a|arg, $req_arg,
,
required argument
],
+verbose,
+help,
);
# call GetOptions() behind the scenes (with error-checking)
$hopt->Get();
$req_arg or ($req_arg = shift);
# usage() called with a message results in non-zero exit code
$req_arg or $hopt->usage(missing required argument);
$verbose and warn "doing stuff nown";
# now do stuff...
<<lessSTATE
This module is still under development, but is being publish on CPAN to satisfy some code which depends on it. The interface may change in a future version and some of the functionality is not yet complete.
SYNOPSIS
This module provides methods which integrate help messages into a Getopt::Long option spec. This gathers documentation and declaration into one place and allows you to utilize perl code to state the default values of options in your online help messages (helping you utilize the single-point-of-truth principle.)
Additionally, it provides DWIM methods (Get) which allow you to cut some standard error-checking code from your scripts. There is even a handy usage() method which eliminates that silly block of code from the beginning.
#!/usr/bin/perl
use warnings;
use strict;
use Getopt::Helpful;
my $var1 = "default";
my $req_arg;
# declare this as our or $main::verbose
our $verbose = 0;
# every option must be passed into the constructor...
my $hopt = Getopt::Helpful->new(
usage => CALLER [options],
[
var=s, $default,
,
"setting for $var1 (default: $var1)"
],
[
a|arg, $req_arg,
,
required argument
],
+verbose,
+help,
);
# call GetOptions() behind the scenes (with error-checking)
$hopt->Get();
$req_arg or ($req_arg = shift);
# usage() called with a message results in non-zero exit code
$req_arg or $hopt->usage(missing required argument);
$verbose and warn "doing stuff nown";
# now do stuff...
Download (0.011MB)
Added: 2006-10-28 License: Perl Artistic License Price:
1091 downloads
Java GetOpt Library 1.0.1
The Java GetOpt library implements option parsing and a common online help behaviour. more>>
Java GetOpt library implements option parsing and a common online help behaviour, including an XML format for topics, command, and options (which can be queried with --help --xml) and support for online browsing with --help --browse.
Whats New in This Release:
ï¿1⁄2 The getopt library can now choose the pluggable look and feel of an application with a standard option "--plaf".
ï¿1⁄2 A new file of default options (.prefs/default.options) can specify a set of common default options for all programs using the getopt library, such as the PLAF.
<<lessWhats New in This Release:
ï¿1⁄2 The getopt library can now choose the pluggable look and feel of an application with a standard option "--plaf".
ï¿1⁄2 A new file of default options (.prefs/default.options) can specify a set of common default options for all programs using the getopt library, such as the PLAF.
Download (0.20MB)
Added: 2005-12-17 License: GPL (GNU General Public License) Price:
1414 downloads
Getopt::Long 2.36
Getopt::Long is an extended processing of command line options. more>>
Getopt::Long is an extended processing of command line options.
SYNOPSIS
use Getopt::Long;
my $data = "file.dat";
my $length = 24;
my $verbose;
$result = GetOptions ("length=i" => $length, # numeric
"file=s" => $data, # string
"verbose" => $verbose); # flag
The Getopt::Long module implements an extended getopt function called GetOptions(). This function adheres to the POSIX syntax for command line options, with GNU extensions.
In general, this means that options have long names instead of single letters, and are introduced with a double dash "--". Support for bundling of command line options, as was the case with the more traditional single-letter approach, is provided but not enabled by default.
<<lessSYNOPSIS
use Getopt::Long;
my $data = "file.dat";
my $length = 24;
my $verbose;
$result = GetOptions ("length=i" => $length, # numeric
"file=s" => $data, # string
"verbose" => $verbose); # flag
The Getopt::Long module implements an extended getopt function called GetOptions(). This function adheres to the POSIX syntax for command line options, with GNU extensions.
In general, this means that options have long names instead of single letters, and are introduced with a double dash "--". Support for bundling of command line options, as was the case with the more traditional single-letter approach, is provided but not enabled by default.
Download (0.040MB)
Added: 2007-08-10 License: Perl Artistic License Price:
806 downloads
Getopt::Tiny 1.02
Getopt::Tiny is yet another command line argument parsing module. more>>
Getopt::Tiny is yet another command line argument parsing module.
SYNOPSIS
use Getopt::Tiny;
my $arg = default value;
my @list;
my %hash;
my $flag;
my %set;
# begin usage info
my (%flags) = (
argx => $arg, # set a parameter
listx => @list, # fill in a list
hashx => %hash, # set key/value pairs
);
my (%switches) = (
flagx => $flag, # on or off
}
# end usage info
getopt(@ARGV, %flags, %switches, $what_comes_after);
Getopt::Tiny::usage(__FILE__, %flags, %switches, files);
or
use Getopt::Tiny;
%flags = ...
%switches = ...
getopt()
Getopt::Tiny::usage();
Getopt::Tiny is yet another argument parsing module. The results of the argument parsing are stored by using references that were provided to getopt(). Usage information is automatically generated. Getopt::Tiny expects all arguments to be switches -- no trailing list of files.
Getopt::Tiny can either call an existing usage() function or it can use its own builtin one. It trys to use the existing one by default. If that fails, it will use its own. It figures out how to describe things by reading the file where call to getopt() originated. In the file where getopt is called, the following two lines must appear exactly as written here:
# begin usage info
# end usage info
Between these two lines, lines that match the pattern of:
someflag => ... # a description
will be noticed and used to document each flag individually.
The usage() function of Getopt::Tiny can be called on its own. It can either have its arguments given to it explicitly or it can default them like getopt().
If a usage function is provided, it will be called with one parameter: the argument that didnt parse.
Getopt::Tiny can be used in situation where it is expected to parse the entire command line and in situations where there will be command line args left over. When Getopt::Tiny is expected to parse the whole command line, do not include a forth argument to getopt(). When it is expected that there will be stuff left over, pass a description of what should be left over as the forth argument to getopt().
<<lessSYNOPSIS
use Getopt::Tiny;
my $arg = default value;
my @list;
my %hash;
my $flag;
my %set;
# begin usage info
my (%flags) = (
argx => $arg, # set a parameter
listx => @list, # fill in a list
hashx => %hash, # set key/value pairs
);
my (%switches) = (
flagx => $flag, # on or off
}
# end usage info
getopt(@ARGV, %flags, %switches, $what_comes_after);
Getopt::Tiny::usage(__FILE__, %flags, %switches, files);
or
use Getopt::Tiny;
%flags = ...
%switches = ...
getopt()
Getopt::Tiny::usage();
Getopt::Tiny is yet another argument parsing module. The results of the argument parsing are stored by using references that were provided to getopt(). Usage information is automatically generated. Getopt::Tiny expects all arguments to be switches -- no trailing list of files.
Getopt::Tiny can either call an existing usage() function or it can use its own builtin one. It trys to use the existing one by default. If that fails, it will use its own. It figures out how to describe things by reading the file where call to getopt() originated. In the file where getopt is called, the following two lines must appear exactly as written here:
# begin usage info
# end usage info
Between these two lines, lines that match the pattern of:
someflag => ... # a description
will be noticed and used to document each flag individually.
The usage() function of Getopt::Tiny can be called on its own. It can either have its arguments given to it explicitly or it can default them like getopt().
If a usage function is provided, it will be called with one parameter: the argument that didnt parse.
Getopt::Tiny can be used in situation where it is expected to parse the entire command line and in situations where there will be command line args left over. When Getopt::Tiny is expected to parse the whole command line, do not include a forth argument to getopt(). When it is expected that there will be stuff left over, pass a description of what should be left over as the forth argument to getopt().
Download (0.005MB)
Added: 2007-04-11 License: Perl Artistic License Price:
926 downloads
Getopt::Popt 0.02
Getopt::Popt is a Perl interface to the popt(3) library. more>>
Getopt::Popt is a Perl interface to the popt(3) library.
SYNOPSIS
use Getopt::Popt qw(:all);
# setup the options array
push @options,new Getopt::Popt::Option(
longName => "long",
shortName => "l",
argInfo => POPT_ARG_STRING,
arg => $qux,
val => $val);
# or, if youre lazy, have Getopt::Popt automagically do the new()
push @options, { shortName => s,
argInfo => POPT_ARG_NONE,
arg => $quux,
val => s
};
# "val"s can be a single character or an integer:
push @options, { longName => xor,
argInfo => POPT_ARG_VAL | POPT_ARGFLAG_XOR,
arg => $quuux,
val => 0xbadf00d # integer
},
Enable automatic help/usage messages (--help or --usage):
push @options, POPT_AUTOHELP;
Create a new popt context:
$popt = new Getopt::Popt(name => $alias_name,
argv => @ARGV,
options => @options,
flags => $flags);
Setup option aliases:
# load some aliases
$popt->readDefaultConfig();
$popt->readConfigFile("/path/to/aliases");
# add your own alias
$alias = new Getopt::Popt::Alias(longName => "taco",
argv => [qw(--flavored --kisses)]);
$popt->addAlias($alias, $alias_flags);
Load options as you would in C:
# loop through the options, using the popt C way:
while(($rc = $popt->getNextOpt()) > 0) {
...
# one way to get the arg val
$bork = $popt->getOptArg();
...
# stuff some args
$popt->stuffArgs(qw(-q -u -x));
...
# start over
$popt->resetContext();
...
}
And handle errors as you would in C:
$errstr = $popt->strerror($rc);
$badopt = $popt->badOption($rc,$badopt_flags);
Or try the new perly way:
eval {
while(defined($val = $popt->getNextOptChar())) {
^^^^-- note!
# $val is a Scalar::Util::dualvar:
if($val eq "c") { # getArgs();
<<lessSYNOPSIS
use Getopt::Popt qw(:all);
# setup the options array
push @options,new Getopt::Popt::Option(
longName => "long",
shortName => "l",
argInfo => POPT_ARG_STRING,
arg => $qux,
val => $val);
# or, if youre lazy, have Getopt::Popt automagically do the new()
push @options, { shortName => s,
argInfo => POPT_ARG_NONE,
arg => $quux,
val => s
};
# "val"s can be a single character or an integer:
push @options, { longName => xor,
argInfo => POPT_ARG_VAL | POPT_ARGFLAG_XOR,
arg => $quuux,
val => 0xbadf00d # integer
},
Enable automatic help/usage messages (--help or --usage):
push @options, POPT_AUTOHELP;
Create a new popt context:
$popt = new Getopt::Popt(name => $alias_name,
argv => @ARGV,
options => @options,
flags => $flags);
Setup option aliases:
# load some aliases
$popt->readDefaultConfig();
$popt->readConfigFile("/path/to/aliases");
# add your own alias
$alias = new Getopt::Popt::Alias(longName => "taco",
argv => [qw(--flavored --kisses)]);
$popt->addAlias($alias, $alias_flags);
Load options as you would in C:
# loop through the options, using the popt C way:
while(($rc = $popt->getNextOpt()) > 0) {
...
# one way to get the arg val
$bork = $popt->getOptArg();
...
# stuff some args
$popt->stuffArgs(qw(-q -u -x));
...
# start over
$popt->resetContext();
...
}
And handle errors as you would in C:
$errstr = $popt->strerror($rc);
$badopt = $popt->badOption($rc,$badopt_flags);
Or try the new perly way:
eval {
while(defined($val = $popt->getNextOptChar())) {
^^^^-- note!
# $val is a Scalar::Util::dualvar:
if($val eq "c") { # getArgs();
Download (0.021MB)
Added: 2007-03-07 License: Perl Artistic License Price:
963 downloads
Getopt::Plus 0.98
Getopt::Plus is a Perl module with options wrapper with standard options, help system and more. more>>
Getopt::Plus is a Perl module with options wrapper with standard options, help system and more.
FILE_SIZE_HUMAN
Map from file size in bytes to human name, as hashref, keys being name (full name, lowercase, no trailing s) and abbrev (one/two-letter abbreviation).
Option Types
Permissable values to the type field of an option specifier.
OPT_FLOAT
OPT_INT
OPT_STRING
OPT_FDLEVEL
OPT_BOOLEAN
Error Codes
ERR_OK
Not an error at all. Hence the name.
ERR_ABNORMAL
Not so much an error as a non-erroneous circumstance worthy of signalling, e.g., grep finding no matches.
ERR_UTILITY
Again, not really an error, rather a utility function being called --- e.g., the --help or --version. This gets an error code because it is almost certainly an error to call from batch scripts.
ERR_USAGE
The program was called wrong.
ERR_IO_READ
Some problem reading from disk or network (system read).
ERR_IO_WRITE
Some problem writing to disk or network (system write).
ERR_DB_READ
Some problem reading from db or similar (application read).
ERR_DB_WRITE
Some problem writing to db or similar (application write).
ERR_EXTERNAL
Some problem with an external application.
ERR_INTERNAL
An internal logic error (the sort of thing that should never happen, but has been caught by an internal assertion or sanity check).
ERR_INPUT
Some problem with the input file (which was read fine, but contains bad data).
<<lessFILE_SIZE_HUMAN
Map from file size in bytes to human name, as hashref, keys being name (full name, lowercase, no trailing s) and abbrev (one/two-letter abbreviation).
Option Types
Permissable values to the type field of an option specifier.
OPT_FLOAT
OPT_INT
OPT_STRING
OPT_FDLEVEL
OPT_BOOLEAN
Error Codes
ERR_OK
Not an error at all. Hence the name.
ERR_ABNORMAL
Not so much an error as a non-erroneous circumstance worthy of signalling, e.g., grep finding no matches.
ERR_UTILITY
Again, not really an error, rather a utility function being called --- e.g., the --help or --version. This gets an error code because it is almost certainly an error to call from batch scripts.
ERR_USAGE
The program was called wrong.
ERR_IO_READ
Some problem reading from disk or network (system read).
ERR_IO_WRITE
Some problem writing to disk or network (system write).
ERR_DB_READ
Some problem reading from db or similar (application read).
ERR_DB_WRITE
Some problem writing to db or similar (application write).
ERR_EXTERNAL
Some problem with an external application.
ERR_INTERNAL
An internal logic error (the sort of thing that should never happen, but has been caught by an internal assertion or sanity check).
ERR_INPUT
Some problem with the input file (which was read fine, but contains bad data).
Download (0.046MB)
Added: 2006-11-02 License: Perl Artistic License Price:
1087 downloads
Getopt::Lucid 0.16
Getopt::Lucid is a clear, readable syntax for command line processing. more>>
Getopt::Lucid is a clear, readable syntax for command line processing.
SYNOPSIS
use Getopt::Lucid qw( :all );
# basic option specifications with aliases
@specs = (
Switch("version|V"),
Counter("verbose|v"),
Param("config|C"),
List("lib|l|I"),
Keypair("define"),
Switch("help|h")
);
$opt = Getopt::Lucid->getopt( @specs );
$verbosity = $opt->get_verbose;
@libs = $opt->get_lib;
%defs = $opt->get_define;
%all_options = $opt->options;
# advanced option specifications
@adv_spec = (
Param("input")->required, # required
Param("mode")->default("tcp"), # defaults
Param("host")->needs("port"), # dependencies
Param("port", qr/d+/ )->required, # regex validation
Param("config", sub { -r } ), # custom validation
Param("help")->anycase, # case insensitivity
);
# example with a config file
use Config::Std;
if ( -r $opt->get_config ) {
read_config( $opt->get_config() => my %config_hash );
$opt->merge_defaults( $config_hash{} );
}
The goal of this module is providing good code readability and clarity of intent for command-line option processing. While readability is a subjective standard, Getopt::Lucid relies on a more verbose, plain-English option specification as compared against the more symbolic approach of Getopt::Long.
Main features:
- Five option types: switches, counters, parameters, lists, and keypairs
- Three option styles: long, short (including bundled), and bare (without dashes)
- Specification of defaults, required options and option dependencies
- Validation of options with regexes or subroutines
- Negation of options on the command line
- Support for parsing any array, not just the default @ARGV
- Incorporation of external defaults (e.g. from a config file) with user control of precedence
<<lessSYNOPSIS
use Getopt::Lucid qw( :all );
# basic option specifications with aliases
@specs = (
Switch("version|V"),
Counter("verbose|v"),
Param("config|C"),
List("lib|l|I"),
Keypair("define"),
Switch("help|h")
);
$opt = Getopt::Lucid->getopt( @specs );
$verbosity = $opt->get_verbose;
@libs = $opt->get_lib;
%defs = $opt->get_define;
%all_options = $opt->options;
# advanced option specifications
@adv_spec = (
Param("input")->required, # required
Param("mode")->default("tcp"), # defaults
Param("host")->needs("port"), # dependencies
Param("port", qr/d+/ )->required, # regex validation
Param("config", sub { -r } ), # custom validation
Param("help")->anycase, # case insensitivity
);
# example with a config file
use Config::Std;
if ( -r $opt->get_config ) {
read_config( $opt->get_config() => my %config_hash );
$opt->merge_defaults( $config_hash{} );
}
The goal of this module is providing good code readability and clarity of intent for command-line option processing. While readability is a subjective standard, Getopt::Lucid relies on a more verbose, plain-English option specification as compared against the more symbolic approach of Getopt::Long.
Main features:
- Five option types: switches, counters, parameters, lists, and keypairs
- Three option styles: long, short (including bundled), and bare (without dashes)
- Specification of defaults, required options and option dependencies
- Validation of options with regexes or subroutines
- Negation of options on the command line
- Support for parsing any array, not just the default @ARGV
- Incorporation of external defaults (e.g. from a config file) with user control of precedence
Download (0.039MB)
Added: 2007-01-16 License: Perl Artistic License Price:
1012 downloads
Getopt::Fancy 0.02
Getopt::Fancy is an object approach to handling command line options, focusing on end user happiness. more>>
Getopt::Fancy is an object approach to handling command line options, focusing on end user happiness.
SYNOPSIS
use Getopt::Fancy;
my $opts = Getopt::Fancy->new();
$opts->add("db", GT => "=s",
EX => " ",
DESC => "The database to dump. Leave unset for all databases.",
DEF => "teen_titans",
ALLOWED => ["--all-databases", "mydb", "teen_titans"],
REGEX => ^[a-zA-Z0-9_]+$,
REQ => 0,
SECTION => "Required DB Params");
# Allow just printing out of set options
$opts->add("check_args", DESC => "Just print all the options", SECTION => "Misc Params");
# Allow user to specify list of options s/he needs help with
$opts->add("help", GT => ":s@", EX => "[option1,option2..]",
DESC => "Give option names and itll print the help for just those options, otherwise all.",
SECTION=>"Misc Params", COMMAS=>1);
# Get the command line options
my $error_msg = $opts->get_options();
print_usage($error_msg) if $error_msg;
print "Will dump this database: $opts->{db} n";
print "User wants help information on these: " . join(", ", @{$opts->{help}}) . "n" if ($opts->{help});
print_usage() if $opts->{help};
print_args() if $opts->{check_args};
sub print_args
{
print $opts->get_values();
exit(0);
}
sub print_usage
{
my $hopts;
my $msg = shift;
$hopts = $opts->{help} unless (scalar @{$opts->{help}} == 0);
print "usage: $0 n";
print $opts->get_usage($hopts);
print "ERROR: $msgn" if $msg;
exit(0);
}
Getopt::Fancy Allows command line options to be all in one place in your script including default values, allowed values, user-friendly descriptions, required flags and pattern matching requirements. Ofttimes script writers skimp on the usage information or have out-dated help information. This modules helps script writers to be better citizens.
This module uses Getopt::Long, so the same rules apply.
<<lessSYNOPSIS
use Getopt::Fancy;
my $opts = Getopt::Fancy->new();
$opts->add("db", GT => "=s",
EX => " ",
DESC => "The database to dump. Leave unset for all databases.",
DEF => "teen_titans",
ALLOWED => ["--all-databases", "mydb", "teen_titans"],
REGEX => ^[a-zA-Z0-9_]+$,
REQ => 0,
SECTION => "Required DB Params");
# Allow just printing out of set options
$opts->add("check_args", DESC => "Just print all the options", SECTION => "Misc Params");
# Allow user to specify list of options s/he needs help with
$opts->add("help", GT => ":s@", EX => "[option1,option2..]",
DESC => "Give option names and itll print the help for just those options, otherwise all.",
SECTION=>"Misc Params", COMMAS=>1);
# Get the command line options
my $error_msg = $opts->get_options();
print_usage($error_msg) if $error_msg;
print "Will dump this database: $opts->{db} n";
print "User wants help information on these: " . join(", ", @{$opts->{help}}) . "n" if ($opts->{help});
print_usage() if $opts->{help};
print_args() if $opts->{check_args};
sub print_args
{
print $opts->get_values();
exit(0);
}
sub print_usage
{
my $hopts;
my $msg = shift;
$hopts = $opts->{help} unless (scalar @{$opts->{help}} == 0);
print "usage: $0 n";
print $opts->get_usage($hopts);
print "ERROR: $msgn" if $msg;
exit(0);
}
Getopt::Fancy Allows command line options to be all in one place in your script including default values, allowed values, user-friendly descriptions, required flags and pattern matching requirements. Ofttimes script writers skimp on the usage information or have out-dated help information. This modules helps script writers to be better citizens.
This module uses Getopt::Long, so the same rules apply.
Download (0.005MB)
Added: 2006-11-04 License: Perl Artistic License Price:
1084 downloads
Secleted [ 0 ] software to compare
Copyright Notice:
Software piracy is theft, Using crack, password, serial numbers, registration codes, key generators is illegal and prevent future software development. The above getopt expar search only lists software in full, demo and trial versions for free download. Download links are directly from our mirror sites or publisher sites, torrent files or links from rapidshare.com, yousendit.com or megaupload.com are not allowed