|
HDK
|
Classes | |
| class | ArgParse::Arg |
Typedefs | |
| using | ArgParse::Action = std::function< void(cspan< const char * > myargs)> |
| Holder for a callback that takes a span of C strings as arguments. More... | |
| using | ArgParse::ArgAction = std::function< void(Arg &arg, cspan< const char * > myargs)> |
Functions | |
| Arg & | ArgParse::add_argument (const char *argname) |
| template<typename... T> | |
| Arg & | ArgParse::add_argument (const char *argname, T...args) |
| Arg & | ArgParse::arg (const char *argname) |
| Shorter synonym for add_argument(). More... | |
| template<typename... T> | |
| Arg & | ArgParse::arg (const char *argname, T...args) |
| Shorter synonym for add_argument(). More... | |
| Arg & | ArgParse::separator (string_view text) |
| using ArgParse::Action = std::function<void(cspan<const char*> myargs)> |
Holder for a callback that takes a span of C strings as arguments.
Definition at line 403 of file argparse.h.
| using ArgParse::ArgAction = std::function<void(Arg& arg, cspan<const char*> myargs)> |
Holder for a callback that takes an Arg ref and a span of C strings as arguments.
Definition at line 407 of file argparse.h.
| Arg& ArgParse::add_argument | ( | const char * | argname | ) |
Add an argument declaration. Ordinary arguments start with a leading - character (or --, either will be accepted). Positional arguments lack a leading -.
The argname consists of any of these options:
Arg::nargs() and Arg::metavar().nargs() and metavar(), and there is no need to call them separately.This method returns an Arg&, so it is permissible to chain Arg method calls. Those chained calls are what communicates the number of parameters, help message, action, etc. See the Arg class for all the possible Arg methods.
|
inline |
Alternate way to add an argument, specifying external storage destinations for the parameters. This is more reminiscent of the older, pre-2.2 API, and also can be convenient as an alternative to extracting every parameter and putting them into variables.
Flags with no parameters are followed by a bool*. Args with parameters must declare them as "%T:NAME", where the "%T" part corresponds to the storage type, d for int, f for float, s for std::string, and L for std::vector<std::string>.
Examples:
ArgParse ap;
bool verbose = false;
ap.add_argument("-v", &verbose)
.help("verbose mode");
float r = 0, g = 0, b = 0;
ap.add_argument("--color %f:R %f:G %f:B", &r, &g, &b)
.help("diffuse color")
.action(ArgParse::store<float>());
Definition at line 362 of file argparse.h.
|
inline |
Shorter synonym for add_argument().
Definition at line 368 of file argparse.h.
|
inline |
Shorter synonym for add_argument().
Definition at line 371 of file argparse.h.
| Arg& ArgParse::separator | ( | string_view | text | ) |
Add a separator with a text message. This can be used to group arguments with section headings.
Example:
ArgParse ap;
ap.separator("Basic arguments:");
ap.add_argument("-v");
ap.add_argument("-a");
ap.separator("Advanced arguments:");
ap.add_argument("-b");
ap.add_argument("-c");
Will print the help section like:
Basic arguments:
-v
-a
Advanced arguments:
-b
-c