CLI 实用程序帮助文件的最佳实践
我已经完成了一个通过 getopt_long 解析参数的命令行实用程序。为了总结一切,我需要实现一个 -h 或 --help 开关,它将打印出参数列表以及描述和默认值。
是否有一个 GNU 框架可供我使用?如果没有,我意识到有几种方法可以手动完成此操作。通常被认为最好的方法是什么?
I've finished implementing a command-line utility that parses arguments via getopt_long. To wrap things up, I need to implement a -h or --help switch that will print out the list of arguments as well as descriptions and default values.
Is there a GNU framework that I can utilize for this? If not, I realize that there are several ways I can do this manually. What's generally seen as the best approach?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
man 3 getopt_long
了解如何使用它。关于在
--help option
的输出中打印什么,您可以阅读http ://www.gnu.org/prep/standards/standards.html#g_t_002d_002dhelp
You can use
See
man 3 getopt_long
on how to use it.And on what to print in the output of your
--help option
, you can readhttp://www.gnu.org/prep/standards/standards.html#g_t_002d_002dhelp
argp_parse() 是当前用于参数解析的 gnu 框架。它取代了 getopt() 和 getopt_long(),后者现在应该被认为是过时的。
argp_parse() is the current gnu framework for argument parsing. It replaces getopt() and getopt_long(), which should now be considered obsolete.