-
Notifications
You must be signed in to change notification settings - Fork 626
Options
For this page, we will assume that there is a cxxopts::Options object declared like so:
cxxopts::Options options(argv[0]);
To add options to the parser, use the function add_options as in the following example:
options.add_options()("option", "description", value)
Where "option" describes the option, "description" is a description of the option for the help, and value is an object describing the type of the argument to the option.
Options must have a long form, and may have a short form. To specify a command line option, the string "option" has the form:
l,long
where the l, is optional. This specifies an option whose long name is long, and whose short name is l.
The parameters to arguments can be parsed, rather than just being recognised as a string. In addition, multiple occurrences of an option can be pushed into a vector. To specify a type for a parameter, the function cxxopts::value is used, which takes a template parameter specifying the type of a parameter, and an optional reference to a variable, into which the parsed value will be stored.