|
| enum class | cli::detail::classifier_t : std::uint8_t {
none
, positional_mark
, short_
, long_
,
windows_style
, subcommand
, subcommand_terminator
} |
| | What a single command-line argument looks like. More...
|
| enum class | cli::extras_mode_t : std::uint8_t {
error = 0
, error_immediately
, ignore
, assume_single_argument
,
assume_multiple_arguments
, capture
} |
| | What to do with command-line arguments that match nothing. More...
|
| enum class | cli::config_extras_mode_t : std::uint8_t { error = 0
, ignore
, ignore_all
, capture
} |
| | What to do with configuration-file entries that match nothing. More...
|
| enum class | cli::prefix_command_mode_t : std::uint8_t { off = 0
, separator_only = 1
, on = 2
} |
| | When an unrecognised argument should stop parsing entirely. More...
|
|
| auto | cli::failure_message::simple (const app_t *app, const error_t &e) -> std::string |
| | Prints a short one-line error message.
|
| auto | cli::failure_message::help (const app_t *app, const error_t &e) -> std::string |
| | Prints the full help text alongside the error.
|
template<typename T>
requires (!std::is_integral_v<T> || (sizeof(T) <= 1U)) |
| auto | cli::detail::default_flag_modifiers (option_t *opt) -> option_t * |
| | Applies the default settings for a flag bound to a non-counting type.
|
template<typename T>
requires (std::is_integral_v<T> && (sizeof(T) > 1U)) |
| auto | cli::detail::default_flag_modifiers (option_t *opt) -> option_t * |
| | Applies the default settings for a flag bound to a counting type.
|
| auto | cli::trigger_on (app_t *trigger_app, app_t *app_to_enable) -> void |
| | Enables one subcommand or option group when another is used.
|
| auto | cli::trigger_on (app_t *trigger_app, std::vector< app_t * > apps_to_enable) -> void |
| | Enables several subcommands or option groups when another is used.
|
| auto | cli::trigger_off (app_t *trigger_app, app_t *app_to_enable) -> void |
| | Disables one subcommand or option group when another is used.
|
| auto | cli::trigger_off (app_t *trigger_app, std::vector< app_t * > apps_to_enable) -> void |
| | Disables several subcommands or option groups when another is used.
|
| auto | cli::deprecate_option (option_t *opt, const std::string &replacement="") -> void |
| | Marks an option as deprecated.
|
| auto | cli::deprecate_option (app_t *app, const std::string &option_name, const std::string &replacement="") -> void |
| | Marks a named option as deprecated.
|
| auto | cli::deprecate_option (app_t &app, const std::string &option_name, const std::string &replacement="") -> void |
| | Marks a named option as deprecated.
|
| auto | cli::retire_option (app_t *app, option_t *opt) -> void |
| | Marks an option as retired.
|
| auto | cli::retire_option (app_t &app, option_t *opt) -> void |
| | Marks an option as retired.
|
| auto | cli::retire_option (app_t *app, const std::string &option_name) -> void |
| | Marks a named option as retired.
|
| auto | cli::retire_option (app_t &app, const std::string &option_name) -> void |
| | Marks a named option as retired.
|
| auto | cli::detail::maybe_narrow (const char *str) -> const char * |
| | Passes a narrow string through unchanged.
|
| auto | cli::detail::maybe_narrow (const wchar_t *str) -> std::string |
| | Narrows a wide string.
|
| auto | cli::capture_extras (extras_mode_t mode) -> bool |
| | Reports whether an extras mode keeps unmatched arguments.
|
The application type: the parser itself.
cli::app_t is the entry point. Construct one, describe the interface with add_option, add_flag, and add_subcommand, then call parse:
int main(int argc, char **argv)
{
std::string file;
app.
add_option(
"-f,--file", file,
"the file to read")->required();
try
{
}
{
}
}
A command-line parser, a subcommand, or an option group.
Definition app.cpp:176
auto parse(int argc, const char *const *argv) -> void
Parses the command line.
Definition app.cpp:3368
auto add_option(std::string option_name, callback_t option_callback, std::string option_description="", bool defaulted=false, std::function< std::string()> func={}) -> option_t *
Adds an option driven by a callback.
Definition app.cpp:2833
auto exit(const error_t &e, std::ostream &out=std::cout, std::ostream &err=std::cerr) const -> int
Prints an error and returns the exit code to give the process.
Definition app.cpp:3517
Base of the errors reporting a problem with the command line.
Definition error.cpp:372
- Note
- Upstream CLI11 offers a CLI11_PARSE macro for the try/catch above. It has no equivalent here: macros are not exported across module boundaries, so the explicit form is the only one.
Subcommands are themselves app_t instances, so everything that works on the top-level parser works on a subcommand. Option groups are subcommands with no name, which is why one class covers all three roles.
Parsing runs in phases: arguments are classified, matched to options or subcommands, collected, then validated and dispatched to callbacks. The phase helpers are the _-prefixed private members near the end of the class.