建议执行命令行界面 [英] Suggestions for implementation of a command line interface
问题描述
我重新设计了一个命令行应用程序,并寻找一种使其使用更直观的方法。传递到命令行应用程序的参数的格式是否有任何约定?
I am redesigning a command line application and am looking for a way to make its use more intuitive. Are there any conventions for the format of parameters passed into a command line application? Or any other method that people have found useful?
推荐答案
我看到很多Windows命令行的细节,但如果你的程序是适用于Linux,我发现 GNU命令行标准是最直观的。基本上,它对命令的长形式使用双连字符(例如, - help
)和短版本的单个连字符(例如, -h
)。您还可以将短版本堆叠在一起(例如, tar -zxvf
filename
I see a lot of Windows command line specifics, but if your program is intended for Linux, I find the GNU command line standard to be the most intuitive. Basically, it uses double hyphens for the long form of a command (e.g., --help
) and a single hyphen for the short version (e.g., -h
). You can also "stack" the short versions together (e.g., tar -zxvf
filename
) and mix 'n match long and short to your heart's content.
GNU网站还列出了标准选项名称
The GNU site also lists standard option names.
getopt库大大简化了解析这些命令。如果C不是您的包, Python 具有类似的库, Perl 。
The getopt library greatly simplifies parsing these commands. If C's not your bag, Python has a similar library, as does Perl.
这篇关于建议执行命令行界面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!