standards: Command-Line Interfaces

1 
1 4.7 Standards for Command Line Interfaces
1 =========================================
1 
1 It is a good idea to follow the POSIX guidelines for the command-line
1 options of a program.  The easiest way to do this is to use 'getopt' to
1 parse them.  Note that the GNU version of 'getopt' will normally permit
1 options anywhere among the arguments unless the special argument '--' is
1 used.  This is not what POSIX specifies; it is a GNU extension.
1 
1    Please define long-named options that are equivalent to the
1 single-letter Unix-style options.  We hope to make GNU more user
1 friendly this way.  This is easy to do with the GNU function
1 'getopt_long'.
1 
1    One of the advantages of long-named options is that they can be
1 consistent from program to program.  For example, users should be able
1 to expect the "verbose" option of any GNU program which has one, to be
1 spelled precisely '--verbose'.  To achieve this uniformity, look at the
1 table of common long-option names when you choose the option names for
1 your program (⇒Option Table).
1 
1    It is usually a good idea for file names given as ordinary arguments
1 to be input files only; any output files would be specified using
1 options (preferably '-o' or '--output').  Even if you allow an output
1 file name as an ordinary argument for compatibility, try to provide an
1 option as another way to specify it.  This will lead to more consistency
1 among GNU utilities, and fewer idiosyncrasies for users to remember.
1 
1    All programs should support two standard options: '--version' and
1 '--help'.  CGI programs should accept these as command-line options, and
1 also if given as the 'PATH_INFO'; for instance, visiting
1 'http://example.org/p.cgi/--help' in a browser should output the same
1 information as invoking 'p.cgi --help' from the command line.
1 

Menu