Are there any standard Command line conventions for dashes and arguments? [duplicate] Are there any standard Command line conventions for dashes and arguments? [duplicate] unix unix

Are there any standard Command line conventions for dashes and arguments? [duplicate]


Read up on the background section of Python's optparse module, it answers some of your questions and exemplifies with some common argument formatting standards seen in the wild. The optparse module author recommends a style that roughly corresponds to the POSIX conventions for command line arguments, with the addition of --double-dashed-long-arguments which comes from the GNU coding standard.


It depends on your taste.

Unix convention is that commands have 2 forms: long and short (one character). To indicate long form we use 2 dashes --. For example --install. Short form is marked with one dash, e.g. -i.

But there is no rules without exceptions. For example command line option of java itself do not follow this convention: -cp and -classpath mean the same and both are marked with one dash only. -version does not have short alias etc.

Slashes are used in windows applications.

I as a java developer prefer to use platform independent conventions (dashes). Moreover various libraries (like cli from jakarta project) supports dashes, so it is easier to implement.


I agree with @Nishant, the single dash is a shorthand notation of a more verbose option.
See the ls Example given by Apache Commons CLI http://commons.apache.org/cli/usage.html#ls_Example