HDK
|
Functions | |
ArgParse::ArgParse () | |
Construct an ArgParse. More... | |
ArgParse::~ArgParse () | |
Destroy an ArgParse. More... | |
ArgParse::ArgParse (int argc, const char **argv) | |
ArgParse::ArgParse (const ArgParse &)=delete | |
const ArgParse & | ArgParse::operator= (const ArgParse &)=delete |
ArgParse::ArgParse (ArgParse &&other) | |
Move constructor. More... | |
ArgParse & | ArgParse::intro (string_view str) |
ArgParse & | ArgParse::usage (string_view str) |
ArgParse & | ArgParse::description (string_view str) |
ArgParse & | ArgParse::epilog (string_view str) |
ArgParse & | ArgParse::prog (string_view str) |
ArgParse & | ArgParse::print_defaults (bool print) |
ArgParse & | ArgParse::add_help (bool add_help) |
ArgParse & | ArgParse::exit_on_error (bool exit_on_error) |
void | ArgParse::abort (bool aborted=true) |
bool | ArgParse::aborted () const |
Reveal whether the current state is aborted. More... | |
void ArgParse::abort | ( | bool | aborted = true | ) |
If called by an argument's action, halts the rest of the command line from continuing to be processed. Call with aborted = false
to unabort and restore operations.
bool ArgParse::aborted | ( | ) | const |
Reveal whether the current state is aborted.
ArgParse& ArgParse::add_help | ( | bool | add_help | ) |
By default, every ArgParse automatically adds a --help
argument that, if invoked, prints the full explanatory help message (i.e., calls print_help()
) and then exits the application with a success return code of 0.
Calling add_help(false)
disable the automatic --help
argument. If you do this but want a help option (for example, you want to call it something different, or not exit the application, or have some other behavior), it's up to the user to add it and its behavior just like any other argument.
ArgParse::ArgParse | ( | ) |
Construct an ArgParse.
ArgParse::ArgParse | ( | int | argc, |
const char ** | argv | ||
) |
|
delete |
|
inline |
Move constructor.
Definition at line 196 of file argparse.h.
ArgParse& ArgParse::description | ( | string_view | str | ) |
Set an optional description of the program, to be printed after the usage but before the detailed argument help.
ArgParse& ArgParse::epilog | ( | string_view | str | ) |
Set an optional epilog to be printed after the detailed argument help.
ArgParse& ArgParse::exit_on_error | ( | bool | exit_on_error | ) |
By default, if the command line arguments do not conform to what is declared to ArgParse (for example, if unknown commands are encountered, required arguments are not found, etc.), the ArgParse (during parse_args()
will print an error message, the full help guide, and then exit the application with a failure return code.
Calling exit_on_error(false)
disables this behavior. In this case, the application is responsible for checking the return code of parse_args()
and responding appropriately.
ArgParse& ArgParse::intro | ( | string_view | str | ) |
Set an optional "intro" message, printed first when –help is used or an error is found in the program arguments.
ArgParse& ArgParse::print_defaults | ( | bool | ) |
If true, this will cause the detailed help message to print the default value of all options for which it was supplied (the default is false).
ArgParse& ArgParse::prog | ( | string_view | str | ) |
Optionally override the name of the program, as understood by ArgParse. If not supplied, it will be derived from the original command line.
ArgParse& ArgParse::usage | ( | string_view | str | ) |
Set the "usage" string, which will be printed after the intro, and preceded by the message "Usage: ".
ArgParse::~ArgParse | ( | ) |
Destroy an ArgParse.