-
Notifications
You must be signed in to change notification settings - Fork 1
Options Format
Options defines several options which can be used
in your [options] "Usage" shortcut.
Options section starts with "Options:"
(case-insensitive), ends with a visibly empty line or the
end of the help message. In "Options" you can define
- the synonymous of a option,
- the description of a option, and
- whether a option expects argument and it's default value.
A quick example:
Usage:
program [options] <arg>
Options:
-h, --help print help message
--version print version of this program
-v, --verbose print more information when running
-i, --input=<file> input file
Different synonymous option should be separated an optional comma, and one space.
-h, -?, --help # with comma
-v --version # without comma
Use one space to separate the option and the argument. For long option,
=(equal) is recommended. argument follows the same rules
of "Argument" in "Usage".
-r <file> --read <file> # without `=`
-w FILE --write=FILE # with`=`
For inline description, use at least 2 spaces to separate the options. For newline description, indent 2 more spaces for each line.
-l --logging open the logging. # Good. Inline description
-r <file> --read <file> read the data from the file. # Good, 2 spaces
if the file does not exists, create one.
# Good, keep the indent
-w FILE --write=FILE
write the data to the file # Good, new line indent 2 more spaces
create one if not exists # Good, keep the indent
raise RuntimeError if fails to create
raise IOError if fails to write
For options that accept argument(s), you can specify a default value.
To do it, first write [default:, and a space ,
followed by your default value, and ends with ]. The whole
block looks like [default: <your-default-value>].
Put this block to the end of your description.
--speed=<km/h> the speed of the ship.[default: inf] # 'inf'
--ship=<name> the name of the ship
create one if not exist. [default: ] # an empty string
