You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lloyd Brookes edited this page Jan 16, 2019
·
8 revisions
Notation rules for setting command-line options.
Option order is insignificant. Whether you set --example at the beginning or end of the arg list makes no difference.
Options with a type of Boolean do not need to supply a value. Setting --flag or -f will set that option's value to true. This is the only type with special behaviour - all other type values act as setter functions.
Three ways to set an option value
--option value
--option=value
-o value
Two ways to set a list of values on options with multiple set
--list one two three
--list one --list two --list three
One way to set a list of values on options with lazyMultiple set
--list one --list two --list three
Short options (alias) can be set in clusters. The following are equivalent:
-a -b -c
-abc
Avoiding ambiguous values
Imagine you'd like to use an example app to search for the query -f.
$ example --search -f
We have an ambiguity issue here: command-line-args will assume we are setting two options (--search and -f). In actuality, we are passing one option (--search) and one value (-f). In cases like this, avoid ambiguity by using --option=value notation:
$ example --search=-f
Please note that --option=value notation is available for long options only (e.g. --option), not short options like -o.