Name : perl-Getopt-Easy
| |
Version : 0.1
| Vendor : obs://build_opensuse_org/devel:languages:perl
|
Release : lp154.6.1
| Date : 2023-01-27 16:58:35
|
Group : Development/Libraries/Perl
| Source RPM : perl-Getopt-Easy-0.1-lp154.6.1.src.rpm
|
Size : 0.01 MB
| |
Packager : https://www_suse_com/
| |
Summary : Parses command line options in a simple but capable way.
|
Description :
Perl puts the command line parameters in the array AATTARGV allowing the user to examine and manipulate it like any other array. There is a long tradition of putting optional single character flags (preceded by a dash) in front of other parameters like so:
% ls -ltr *.h *.c % tar -tvf all.tar % ps -ax -U jsmith
Many Getopt::* modules exist to help with the parsing of these flags out of AATTARGV. For the author, Getopt::Std was visually too cryptic and Getopt::Long was too large and complex for most normal applications. Getopt::Easy is small, easy to understand, and provides a visual clarity.
There are two things exported: get_options() and %O.
get_options has 1 required parameter and 2 optional ones. The first is a string describing the kind of options that are expected. It is a space separated list of terms like this:
get_options \"v-verbose f-fname=\";
If the -v option is given on the command line %O{verbose} will be set to 1 (true). If the -f option is given then another argument is expected which will be assigned to $O{fname}.
Before parsing AATTARGV, $O{verbose} will be initialized to 0 (false) and $O{fname} to \"\" (unless they already have a value).
If you give an unknown option get_options() will complain and exit:
% prog -vX unknown option: -X %
These conventions are implemented by Getopt::Easy:
* *
The options can come in any order.
* *
Multiple boolean options can be bundled together.
* *
A command line argument of \'--\' will cause argument parsing to stop so you can parse the rest of the options yourself.
* *
Parsed arguments are removed from AATTARGV.
These invocations are equivalent:
% prog -v -f infile % prog -f infile -v # different order % prog -v -finfile % prog -vf infile % prog -vfinfile
This shows that the space between -f and infile is optional and that you _can_ bundle -f with -v but -f must be the _last_ option in the bundle.
The optional second parameter to get_options() is a usage message to be printed when an illegal option is given.
get_options \"v-verbose f-fname=\", \"usage: prog [-v] [-f fname]\";
Now if an unknown option is given, the same error message will be printed, as above, followed by the usage message.
% prog -vX unknown option: -X usage: prog [-v] [-f fname] %
|
RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl:/CPAN-G/15.4/noarch |