-
-
Notifications
You must be signed in to change notification settings - Fork 725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tb_option_done 只认 -f=a.txt 这种形式,却不认 -f a.txt 这种形式 #250
Comments
我在 tb_option_done 的源码里看到,tbox目前是采用这种方式获取选项的value的: 也就是,必须写等号。 |
请问作者,我是否可以修改代码以支持无等号的形式? |
I would like to ask the author, can I modify the code to support the form without equal sign? |
可以 |
Can |
|
根据TB_OPTION_MODE_KEY_VAL的文档
tb_option_done能够支持以下2种风格的命令行参数:
-k=value
-k value
但我发现,只要缺了 = 号,tb_option_done就会抱怨。
当我运行
build/linux/x86_64/debug/myapp -f=a.txt
时,看到如下抱怨:
[tbox]: [option]: [error]: myapp: no option value '--f=' at tb_option_done(): 466, src/tbox/utils/option.c
下面是我的option
`
static tb_option_item_t g_options[] =
{
{ 'f'
, "config"
, TB_OPTION_MODE_KEY_VAL
, TB_OPTION_TYPE_CSTR
, "加载指定配置文件"
}
, {'h', "help", TB_OPTION_MODE_KEY, TB_OPTION_TYPE_BOOL, "显式本帮助信息并退出"}
, {'-', tb_null, TB_OPTION_MODE_MORE, TB_OPTION_TYPE_NONE, tb_null}
};
`
期待的结果
build/linux/x86_64/debug/myapp -f=a.txt
时不报错
错误信息
[tbox]: [option]: [error]: myapp: no option value '--f=' at tb_option_done(): 466, src/tbox/utils/option.c
相关环境
Debian GNU/Linux 12 (bookworm)
gcc (Debian 12.2.0-14) 12.2.0
其他信息
无
The text was updated successfully, but these errors were encountered: