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?
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 (eg, --help
) and a single hyphen for the short version (eg, -h
). You can also "stack" the short versions together (eg, tar -zxvf
filename
) and mix 'n match long and short to your heart's content.
The GNU site also lists standard option names.
The getopt library greatly simplifies parsing these commands. If C's not your bag, Python has a similar library, as does Perl.
If you are using C# try Mono.GetOptions, it's a very powerful and simple-to-use command-line argument parser. It works in Mono environments and with Microsoft .NET Framework.
EDIT: Here are a few features
One thing I like about certain CLI is the usage of shortcuts .
Ie, all the following lines are doing the same thing
myCli.exe describe someThing
myCli.exe descr someThing
myCli.exe desc someThing
That way, the user may not have to type the all command every time.
链接地址: http://www.djcxy.com/p/30414.html上一篇: 行参数转换为C#中的字符串[]
下一篇: 有关实现命令行界面的建议