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.
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.
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.
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].
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With