|
kaycxx-cli
C++ CLI library
|
A flag does not take a value. An option takes a value and converts it to its declared C++ type.
Register a flag with a long name and an optional one-character alias.
The description is optional. A flag without a description remains parseable but is omitted from the detailed help listing.
Both --quiet and -q set the first flag. Read flags with args::get. An absent flag returns false.
Flags do not accept values. For example, --quiet=true is rejected.
The option template argument defines the parsed value type. The value name is used as a placeholder in help and error output.
The parser accepts long option values as the next argument or after =. Short option values are read from the next argument.
Grouped short flags such as -qv and attached short option values such as -j4 are rejected. Write them as separate arguments instead.
Set a default through the returned handle. Handle configuration methods return the handle again, so the configured handle can be stored directly.
An option with a default is always available through args::get. For an option without a default, check args::has before reading it.
An ordinary option may occur only once. Repeating it is reported as a parsing error.
Use repeatable_option when the same option may occur multiple times. Its handle reads all converted values as a vector in command-line order.
For example, --include first -I second --include=third produces std::vector<std::string>{ "first", "second", "third" }. An absent repeatable option is unavailable through args::get unless it has a default value.
Mark flags and options that select alternative command actions with action(). At most one explicitly specified action may occur on a command line. Omitting all actions is valid and lets the application perform its default action.
Normal switches are not part of this restriction and may be combined with an action. Default option values do not select an action. Only an action explicitly present on the command line participates in the exclusivity check.