A class to specify a command-line option. More...
#include "cmdline_option.h"
Public Member Functions | |
Option () | |
Option (const char *name, const std::string &description) | |
Option & | operator+ (const Argument &arg) |
operator bool () const | |
Option & | required () |
specifies that the option is required More... | |
Option & | allow_multiple () |
specifies that multiple such options can be specified More... | |
bool | is (const std::string &name) const |
std::string | syntax (int format) const |
std::string | usage () const |
Public Member Functions inherited from MR::vector< Argument > | |
vector () | |
Public Attributes | |
const char * | id |
the option name More... | |
std::string | desc |
the option description More... | |
ArgFlags | flags |
option flags (AllowMultiple and/or Optional) More... | |
A class to specify a command-line option.
Command-line options that are accepted by a particular command are specified as an array of Option objects, terminated with an empty Option (constructed using default parameters). Please refer to Command-line parsing for more information.
The list of options is provided using the OPTIONS macro, like this:
The example above specifies that the application accepts four options, in addition to the standard ones (see Command-line parsing for details). The first option is a simple switch: specifying '-exact' on the command line will cause the application to behave differently. The next options all expect an additional argument, supplied using the Argument class. Note that the description field of the Argument class is unused in this case. Multiple additional arguments can be specified in this way using the addition operator.
Options can also be specified as required (see required() function), or as multiple (see allow_multiple() function).
Definition at line 343 of file cmdline_option.h.
|
inline |
Definition at line 345 of file cmdline_option.h.
|
inline |
Definition at line 347 of file cmdline_option.h.
|
inline |
specifies that multiple such options can be specified
See required() for details.
Definition at line 385 of file cmdline_option.h.
|
inline |
Definition at line 390 of file cmdline_option.h.
|
inline |
Definition at line 354 of file cmdline_option.h.
Definition at line 350 of file cmdline_option.h.
|
inline |
specifies that the option is required
An option specified as required must be supplied on the command line. For example:
Definition at line 378 of file cmdline_option.h.
std::string MR::App::Option::syntax | ( | int | format | ) | const |
std::string MR::App::Option::usage | ( | ) | const |
std::string MR::App::Option::desc |
the option description
Definition at line 361 of file cmdline_option.h.
ArgFlags MR::App::Option::flags |
option flags (AllowMultiple and/or Optional)
Definition at line 363 of file cmdline_option.h.
const char* MR::App::Option::id |
the option name
Definition at line 359 of file cmdline_option.h.