命令行动词参数的约定 -a vs --arg

Conventions for command line verb arguments -a vs --arg

我刚刚注意到动词式命令参数的模式(在 git 和 .NET 的 CommandLineParser 库中),想知道是否有人可以确认:

myprog dothis -a "someArg"

单横线前缀和双横线前缀有什么区别?单破折号前缀是否始终用于单字母参数说明符,而双破折号前缀始终用于参数的 "long name"?

是否有某个地方有正式的约定来推动这一点,或者它是否是一种普遍接受的非正式做法? (还是我什么都没做?)

只是好奇...我从来没有注意到 git 中的模式,CommandLineParser 文档非常薄,一些博客 post 或其他涉及约定。

(就此而言...这种 verb/args 的风格叫什么?我似乎找不到太多关于它的东西)

来自维基百科:https://en.wikipedia.org/wiki/Command-line_interface

Unix-like 系统中的选项约定

In Unix-like systems, the ASCII hyphen-minus begins options; the new (and GNU) convention is to use two hyphens then a word (e.g. --create) to identify the option's use while the old convention (and still available as an option for frequently-used options) is to use one hyphen then one letter (e.g. -c); if one hyphen is followed by two or more letters it may mean two options are being specified, or it may mean the second and subsequent letters are a parameter (such as filename or date) for the first option.

Two hyphen-minus characters without following letters (--) may indicate that the remaining arguments should not be treated as options, which is useful for example if a file name itself begins with a hyphen, or if further arguments are meant for an inner command (e.g. sudo). Double hyphen-minuses are also sometimes used to prefix "long options" where more descriptive option names are used. This is a common feature of GNU software. The getopt function and program, and the getopts command are usually used for parsing command-line options.

posix conventiongetopt

但情况并非总是如此,例如javafind.

另请参阅:

https://golang.org/pkg/flag/

http://docs.oracle.com/javase/8/javafx/api/javafx/application/Application.Parameters.html