Confusing behavior when order of long/short options are swapped
还没有人认领这个 Issue。
评估
调研方向
从 option_description::option_description(const char*, const value_semantic*) 和文档中规定的名称格式规则开始。使用 "h,help" 在简单测试程序中复现该行为,然后确定是否应明确接受或拒绝交换顺序的名称。完成的标准是:误用不再产生令人困惑的运行时行为,并且预期行为已由测试覆盖。
由索引模型根据 Issue 内容生成。
描述
Adding an option like this:
desc.add_options()( "h,help", "Print help and exit" );
In a simple test program and then trying to use --help results in a confusing error:
$ ./prog --help
libc++abi.dylib: terminating with uncaught exception of type boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::program_options::unknown_option> >: unrecognised option '--help'
The documentation for option_description::option_description(const char*, const value_semantic*) says:
The 'name' parameter is interpreted by the following rules:
if there's no "," character in 'name', it specifies long name
otherwise, the part before "," specifies long name and the part after -- short name.
However, it is easy for new users of this library to think that swapping them is OK.
The reason for this limitation isn't clear to me -- presumably, if one is "long" and the other "short", providing them in either order should be OK, and a simple test can tell which is which. In either case, the error message on misuse is needlessly cryptic and could probably be turned into an error thrown from option_description::option_description. This seems reasonable, since using "h,help" as the option name results in bad behavior regardless: the resulting executable has options --h and -h.
- 主要语言
- C++
- 星标
- 136
- 派生
- 117
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
boostorg/program_options 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 45/100
boostorg/program_options#147 ·
-
难度 5/5 一周以上 新手友好度 30/100
boostorg/program_options#146 ·
-
难度 2/5 1-3 小时 新手友好度 45/100
boostorg/program_options#144 ·
-
难度 3/5 1-2 天 新手友好度 45/100
boostorg/program_options#142 ·
-
难度 3/5 1-2 天 新手友好度 30/100
boostorg/program_options#139 ·
查看 boostorg/program_options 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 90/100
AXERA-TECH/ax-llm#77 ·
-
难度 1/5 1 小时以内 新手友好度 90/100
games-on-whales/wolf#509 ·
-
难度 2/5 1-3 小时 新手友好度 74/100
-
bug-unconfirmed
难度 2/5 1-3 小时 新手友好度 76/100
-
难度 2/5 1-3 小时 新手友好度 74/100
NVIDIA/cuda-samples#453 ·