我只想接受长格式的选项的可选参数 选项。
假设我定义了-v
,--verbose
选项,并为argp提供了可选参数:
static struct argp_option opt_global[] =
{
{ "verbose",'v',"level",OPTION_ARG_OPTIONAL,"Increase or set the verbosity level.",-1},...
}
我现在只想在以长选项形式给出时接受可选参数。
所以
--verbose=4
将接受4
作为详细的可选参数。
但是对于简短的选项形式,不应接受可选参数:
| Command Line | Handled as |
|==============|===================|
| -vv | -v -v |
| -vx | -v -x |
| -v4 | -v -4 |
并假设我也有-o file
来定义输出文件:
| Command Line | Handled as |
|==============|===================|
| -vo file | -v -o file |
| -vofile | -v -o file |
无论如何,我还是希望帮助输出看起来像这样:
-v,--verbose[=level] Increase or set the verbosity level.
这对GNU argp可行吗?
通过阅读文档并玩耍,我会假设“否”,但也许我 错过了什么。