Are there standard command line conventions for dashes and arguments?

What are the command line conventions regarding using 2 dashes, 1 dashes or just missing parameters and just reading the inputs in order?

I understand that there are many options, but are there any conventions as an industry standard (e.g. in Java, or C or Python)?

+4
source share
3 answers

Read in the background section of the Ppton optparse module, it answers some of your questions and illustrates some common standards for formatting arguments, wildlife. The author of the optparse module recommends a style that roughly follows the POSIX conventions for command line arguments , with the addition of double-dashed-long arguments that come from the GNU coding standard.

+6
source

It depends on your taste.

The Unix convention is that teams have 2 forms: long and short (one character). To indicate the long form, we use two dashes -. For example --install . The short form is marked with a single dash, for example. -i .

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

Slashes are used in Windows applications.

As a Java developer, I prefer to use platform-independent conventions (dashes). In addition, various libraries (for example, cli from the jakarta project) support dashes, so they are easier to implement.

+2
source

I agree with @Nishant, a single dash is an abbreviation for a more detailed version.
See the ls example provided by the Apache Commons CLI http://commons.apache.org/cli/usage.html#ls_Example

+1
source

Source: https://habr.com/ru/post/1379129/


All Articles