I want to accept a optional argument to an option only with the long form of the option.
Assume I define the option -v
, --verbose
with a optional argument for argp:
static struct argp_option opt_global[] =
{
{ "verbose", 'v' , "level", OPTION_ARG_OPTIONAL, "Increase or set the verbosity level.", -1},
...
}
I now want to accept the optional argument only when given with the long option form.
So
--verbose=4
will accept the 4
as a optional argument for verbose.
But with the short option form, the optional argument should not be accepted:
| Command Line | Handled as |
|==============|===================|
| -vv | -v -v |
| -vx | -v -x |
| -v4 | -v -4 |
And assuming I also have -o file
to define a output file:
| Command Line | Handled as |
|==============|===================|
| -vo file | -v -o file |
| -vofile | -v -o file |
Anyway I stiil want the help output to look like this:
-v, --verbose[=level] Increase or set the verbosity level.
Is this doable with GNU argp?
From reading the docs and playing around, I would assume "No", but maybe I missed something.