Is there a style guide to writing command line applications' arguments on unix platforms? Coming from the iOS world I'm thinking of something akin to the Human Interface Guidelines (HIG). I'm writing a script in Python that can take parameters.
Example: How to name arguments, when to use -dash
or --dou开发者_开发百科bleDash
.
Look at this standard library module: http://docs.python.org/library/argparse.html
It will make your life much easier implementing a command line interface, and you end up using its style guide.
Note that argparse only became available in Python 2.7 (or 3.2, in the 3.x series). Before that there was http://docs.python.org/library/optparse.html, which results in a similar command line interface, but is not as much fun to use.
The GNU Coding Standards have a section on command line programs.
For a posixy feel, you shouldn't only provide the standard command line options, both short and long, but also, if possible, adhere to reading from the standard input (or the command line) and writing to the standard output, and only overriding the output with an option (like -o
/--output
). That's what one expects of most GNU command line tools.
Read The Art of Unix Usability http://www.catb.org/~esr/writings/taouu/taouu.html
精彩评论