wex v24.10.0
|
Offers a command line class. More...
#include <wex/core/cmdline.h>
Public Types | |
enum | option_t { FLOAT , INT , STRING } |
Types for command line options. More... | |
typedef std::vector< std::pair< const std::vector< std::string >, std::function< void(bool on)> > > | cmd_switches_t |
Switches: | |
typedef std::vector< std::pair< const std::vector< std::string >, std::pair< option_t, std::function< void(const std::any &any)> > > | cmd_options_t) |
Options: | |
typedef std::pair< const std::pair< const std::string, const std::string >, std::function< void(std::vector< std::string >)> > | cmd_params_t |
Params (currently only string value supported): | |
Public Member Functions | |
cmdline (const cmd_switches_t &s=cmd_switches_t(), const cmd_options_t &o=cmd_options_t(), const cmd_params_t &p=cmd_params_t(), bool add_standard_options=true) | |
Default constructor, adds standard options. | |
~cmdline () | |
Destructor. | |
bool | parse (data::cmdline &data) |
Parses the command line arguments and invokes callbacks. | |
bool | parse_set (data::cmdline &data) const |
Parses the command line arguments and invokes callbacks. | |
Static Public Member Functions | |
static std::string | get_output () |
Returns output. | |
static std::string | get_scriptout () |
Returns script out. | |
static bool | is_echo () |
Returns echo. | |
static bool | is_output () |
Returns output. | |
static bool | use_events () |
For some tests events can be preferred over direct code. | |
Offers a command line class.
Besides offering the switches, options and params, it also adds standard options:
wex::cmdline::cmdline | ( | const cmd_switches_t & | s = cmd_switches_t(), |
const cmd_options_t & | o = cmd_options_t(), | ||
const cmd_params_t & | p = cmd_params_t(), | ||
bool | add_standard_options = true ) |
Default constructor, adds standard options.
s | switches |
o | options |
p | params |
add_standard_options | add standard options |
bool wex::cmdline::parse | ( | data::cmdline & | data | ) |
Parses the command line arguments and invokes callbacks.
Returns false if error is found, or exit condition is true.
bool wex::cmdline::parse_set | ( | data::cmdline & | data | ) | const |
Parses the command line arguments and invokes callbacks.
Options are specified according to ex :set specification. [option[=[value]] ...][nooption ...][option? ...][all] Returns false if option was not found.
|
static |
For some tests events can be preferred over direct code.
Returns this setting, default events are not preferred.