Flags
Flags are named inputs that do not take values. Register them in
Command.flags for one command, in Executor.flags for the entire command
tree, or in GroupCommand.propagatedFlags for a group and its descendants.
The executor also registers --dry-run, --verbose, and --version globally;
--help is built into every command registry.
The examples below show help without its ANSI colors. Flag expressions are
optional and therefore appear inside [ ... ].
BooleanFlag
Section titled “BooleanFlag”BooleanFlag is a concrete Flag that parses whether a named switch is on or
off. It accepts --name, an optional one-letter -n alias, and its short alias
inside a bundle such as -fn. defaultValue is returned when the flag is
omitted and defaults to false. Setting negatable: true also registers
--no-name, which sets the parsed value to false.
Use description to explain the flag in help. Set hidden: true to keep all of
its spellings parseable while omitting it from the default help formatter.
CountFlag
Section titled “CountFlag”CountFlag is a concrete Flag that counts how many times its spelling is
supplied. It accepts --name, an optional one-letter alias, repeated long or
short spellings, and repeated short aliases in a bundle. An omitted count flag
has the value 0.
Register it through Command.flags, Executor.flags, or
GroupCommand.propagatedFlags. Its description, short, and hidden
configuration have the same help behavior as a boolean flag.
