Command Line app arguments style guide Command Line app arguments style guide unix unix

Command Line app arguments style guide


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.