Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Style guide rules for multi-word command line arguments?

Does anyone know of any command line interface style guides with rules about how to present multi-word options?

There are many varieties possible.

Many programs, like grep, use a two-hyphen prefix and a hyphen separator. For example:

--byte-offset

Some programs, like find, use a one-hyphen prefix and an underscore separator. For example:

-ignore_readdir_race

Some programs, like java, use a one-hyphen prefix and a colon separator. For example:

-verbose:gc

A few programs, use a two-hyphen prefix and an underscore separator. I haven't yet found a common example of this but my company has internal utilities that use this style. For example:

--save_only

Some programs even support multiple varieties.

GNU Coding Standards and The Art of Unix Usability are great references but I don't see information about multi-word options specifically.

I'm looking for links to command line interface style guides that specifically address multi-word options. I don't care what rules or advice these guides offer as long as they mention multi-word options.

like image 999
jwfearn Avatar asked Feb 06 '19 17:02

jwfearn


People also ask

How do you write a command line argument?

A command line argument is simply anything we enter after the executable name, which in the above example is notepad.exe. So for example, if we launched Notepad using the command C:\Windows\System32\notepad.exe /s, then /s would be the command line argument we used.

How many command line arguments can be passed?

We pass arguments in a function, we can pass no arguments at all, single arguments or multiple arguments to a function and can call the function multiple times. Example: Python.

What is used for all command line arguments?

Command line arguments are passed to the main function as argc and argv. Command line arguments are used to control the program from the outside. argv[argc] is a Null pointer. The name of the program is stored in argv[0], the first command-line parameter in argv[1], and the last argument in argv[n].


1 Answers

You may find the libc manual and its chapter concerning Program Argument Syntax Conventions useful. The fragment relevant to your question is:

GNU adds long options to these conventions. Long options consist of ‘--’ followed by a name made of alphanumeric characters and dashes. Option names are typically one to three words long, with hyphens to separate words. Users can abbreviate the option names as long as the abbreviations are unique.

like image 121
jmich Avatar answered Sep 25 '22 14:09

jmich