views:

57

answers:

3

On a Linux system it is typical to type progname --help in order to view the help output for that program. After this you will see a description like: progname [SWITCHES] [FILES]... [ETC]

My question is; is there a standardized syntax for his sort of (command-line use) documentation?

In order to describe things like optional switches, multiple parameters (like a file list), switch patterns, etc. It seems like there would be a standard so that anyone who knows it, could accurately interpret your documentation.

Thanks.

Note: This is purely about writing my own documentation, not parsing arguments.

+2  A: 

The GNU Getopt Library is likely the most standard way to parse arguments now. There are library bindings for most any language you'll be using.

msw
Thanks, but I was getting at writing my own documentation, not parsing arguments. Just edited for clarity.
sigint
If you are using GNU libc, you can use `argp`, which is similar to getopt but generates the `--help` output for you automagically: http://www.gnu.org/s/libc/manual/html_node/Argp.html
John Ledbetter
+1  A: 

Do you want to implement such help in your program? There are standard Linux commands for this:

getopt - to use in a script http://linuxmanpages.com/man1/getopt.1.php

getopt, getopt_long - to use in C+/C++ http://linuxmanpages.com/man3/getopt.3.php

Alex Farber
A: 

There is http://www.gnu.org/prep/standards/standards.html#g_t_002d_002dhelp and http://www.gnu.org/prep/standards/standards.html#Option-Table

But i can't see a strict standard definition...

OMG_peanuts