Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command Line app arguments style guide

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 --doubleDash.

like image 240
JoePasq Avatar asked Aug 31 '11 01:08

JoePasq


3 Answers

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.

like image 124
Ben Avatar answered Sep 24 '22 04:09

Ben


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.

like image 25
Kerrek SB Avatar answered Sep 24 '22 04:09

Kerrek SB


Read The Art of Unix Usability http://www.catb.org/~esr/writings/taouu/taouu.html

like image 43
tripleee Avatar answered Sep 23 '22 04:09

tripleee