仅在 boost::program_options 中的短选项
如果没有 boost 中的多头选项,那么如何指定空头选项呢?
(",w", po::value<int>(), "Perfrom write with N frames")
生成这个
-w [ -- ] arg : Perfrom write with N frames
有什么办法只指定短选项吗?
How would one go about specifying short options without their long counterparts in boost?
(",w", po::value<int>(), "Perfrom write with N frames")
generates this
-w [ -- ] arg : Perfrom write with N frames
Any way to specify short options only?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用命令行解析器,有一种方法可以设置不同的样式。因此,解决方案是仅使用长选项并启用allow_long_disguise 样式,该样式允许用一个破折号指定长选项(即“-long_option”)。这是一个例子:
不过,描述输出会有一个小问题:
这个问题很难修复,因为这是用来形成此输出的:
对此想到的唯一修复方法是替换“-- ” 在结果字符串中带有“-”。例如:
您能做的最好的事情就是修复打印空的长选项描述的代码,并向库的作者发送补丁。
If you are using command line parser, there is a way to set different styles. So the solution would be to use only long options and enable allow_long_disguise style which allows long options to be specified with one dash (i.e. "-long_option"). Here is an example:
There will be a little problem with the description output though:
And that one is hard to fix because this is what is being used to form this output:
The only fix for this that comes to mind is replacing "--" with "-" in resulting string. For example:
The best thing you can do is to fix the code where it prints empty long option description and send a patch to the author of the library.