Each command line parameter must be defined in the form
short_names[*|!] [/ long_name[*|!][=opt_name]] type [ options ]
A short_name is a single letter (small or capital) or a single digit. long_name
is a longer (more descriptive) option name. On the command line a short name
will be preceded by a single dash (e.g.
-a) and a long version will
be preceded by two dashes (e.g.
--all). If a long parameter name is not
necessary, you may specify only the short one (and the slash need not appear).
In order to specify a parameter that only has a long name set short_names to
It is possible to have multiple short options, so for example setting short_name to ’aA’
and long_name to ’all’ would allow to specify the command line switch as
--all, all of them doing the same thing. long options can
be followed by a descriptive designation (See opt_name.).
makes the argument optional. This can be specified for short and long options
long_name makes the option boolean.
This allows one to combine a boolean short option with a long option with an optional
or mandatory argument or to combine a boolean long option with a short option with
an optional or mandatory argument. A
! doesn’t make sense if the option’s
o* / oparam* string "Both short and long option have an optional" "argument" p* / pparam string "Short option has an optional argument," "long option requires an argument." q / qparam* string "Short option reqires an argument," "long option has an optional argument." P* / Pparam! string "Short option has an optional argument," "long option none." Q!/ Qparam* string "Short option has no argument, long option has an" "optional argument."
type must be one of
flag. The first four should be self-explanatory. The last is a "switch"
option that takes no arguments. For C output and if --gnulib
(See gnulib.) is set on the command line additionally the following types are
long (for long int),
ulong (for unsigned long int),
intmax (for intmax_t, defined in Gnulib),
uintmax (for uintmax_t),
The following four options are supported. They may appear in any order and except for descriptions only one of each field may be defined per option.
usage ()function. If one line is not enough then specify multiple descriptions, one per line and each of them in double quotes. If the description starts in the 1st column in the Genparse file then it will also be printed in the 1st column in the
#gp_include another.gp. Only parameter definitions are allowed in the included file, no global directives.
__ERR_MSG__("%s: invalid argument"). This message will be printed when either the conversion function failed or when the argument was out of range (See range.). Assumes to contain one
%swhich will be replaced with the agrument which could not be converted. Only available when Genparse is invoked with --gnulib (See gnulib.), ignored otherwise.
Optionally a conversion function can be added as a second argument, e. g.
__ERR_MSG__("%s: invalid argument", quotearg). This would lead to an
error message like
error (EXIT_FAILURE, 0, "%s: invalid argument", quotearg (optind)).
__CODE__(printf ("Parameter x was set");). The specified code can extend over more than one line. In order to give Genparse the chance to indent the code properly, do not mix space and tab indentations in one
getopt_long ()). This new field will get the same name as the result field it is related to but with an