是否有一个"标准"命令行/壳帮助文本格式? [英] Is there a "standard" format for command line/shell help text?
问题描述
如果不是,这里是一个事实上的标准?基本上我正在写像这样的命令行帮助文本:
If not, is here a de facto standard? Basically I'm writing a command line help text like so:
usage: app_name [options] required_input required_input2
options:
-a, --argument Does something
-b required Does something with "required"
-c, --command required Something else
-d [optlistitem1 optlistitem 2 ... ] Something with list
我做了,从基本上只是阅读的各种工具的帮助文字,但有没有准则或东西的清单?比如,我用方括号或括号?怎么样的间距?如果参数是一个列表?谢谢!
I made that from basically just reading the help text of various tools, but is there a list of guidelines or something? For example, do I use square brackets or parenthesis? How are the spacing? What if the argument is a list? Thanks!
推荐答案
通常情况下,你的帮助输出应包括:
Typically, your help output should include:
- 的应用程序做什么说明
- 使用的语法,其中:
- 使用
[选项]
来表示,其中的选项去 -
arg_name
的要求,单数ARG -
[arg_name]
一个可选的,奇异ARG -
arg_name ...
的要求ARG其中可以有很多(这是罕见的) -
[arg_name ...]
为的任何编号可以提供一个ARG - 注意,
arg_name
应该是描述性的,短的名字,在低,蛇的情况下
- Description of what the app does
- Usage syntax, which:
- Uses
[options]
to indicate where the options go arg_name
for a required, singular arg[arg_name]
for an optional, singular argarg_name…
for a required arg of which there can be many (this is rare)[arg_name…]
for an arg for which any number can be supplied- note that
arg_name
should be a descriptive, short name, in lower, snake case
- 有一个简短的说明
- 表示的缺省值,如果有一个
- 显示可能的值,如果适用)
- 请注意,如果一个选项可以接受缩写形式(如
-l </ code>)或长格式(如
- 列表
),一起包括它们在同一行,因为它们的描述将是相同的
- having a short description
- showing the default value, if there is one
- showing the possible values, if that applies)
- Note that if an option can accept a short form (e.g.
-l
) or a long form (e.g.--list
), include them together on the same line, as their descriptions will be the same
还要注意,这是很好的形式同时接受
-h
和- 帮助
来触发此消息的和的,如果用户弄乱了命令行语法,如您应该显示这个信息省略了必需的参数。Note further that it's good form to accept both
-h
and--help
to trigger this message and that you should show this message if the user messes up the command-line syntax, e.g. omits a required argument.这篇关于是否有一个&QUOT;标准&QUOT;命令行/壳帮助文本格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- Uses
- 使用