![]() |
Scarab
v2.4.2
Project 8 C++ Utility Library
|
Adds the ability to create options and subcommands that are tied to a main_app's master config. More...
#include <application.hh>
Classes | |
struct | app_option_holder |
struct | app_option_holder_bool_flag |
struct | app_option_holder_typed |
struct | app_option_holder_vector_typed |
Public Member Functions | |
config_decorator (main_app *a_main, app *a_this_app) | |
virtual | ~config_decorator () |
main_app * | main () const |
app * | this_app () const |
config_decorator * | add_config_subcommand (std::string a_subcommand_name, std::string a_description="") |
Add a subcommand that is linked to a particular main_app and can create options that modify that main_app's master config. More... | |
template<typename T , CLI::enable_if_t< ! CLI::is_vector< T >::value, CLI::detail::enabler > = CLI::detail::dummy> | |
CLI::Option * | add_config_option (std::string a_name, std::string a_master_config_addr, std::string a_description="") |
Add an option that gets automatically added to the master config of a main_app. More... | |
template<typename T , CLI::enable_if_t< ! CLI::is_vector< T >::value, CLI::detail::enabler > = CLI::detail::dummy> | |
CLI::Option * | add_config_multi_option (std::string a_name, std::string a_master_config_addr, std::string a_description="") |
Add an option that gets automatically added to the master config of a main_app. More... | |
template<typename T , CLI::enable_if_t< std::is_integral< T >::value &&! CLI::is_bool< T >::value, CLI::detail::enabler > = CLI::detail::dummy> | |
CLI::Option * | add_config_flag (std::string a_name, std::string a_master_config_addr, std::string a_description="") |
template<typename T , CLI::enable_if_t< CLI::is_bool< T >::value, CLI::detail::enabler > = CLI::detail::dummy> | |
CLI::Option * | add_config_flag (std::string a_name, std::string a_master_config_addr, std::string a_description="") |
Protected Types | |
using | conf_dec_ptr_t = std::unique_ptr< config_decorator > |
Protected Attributes | |
main_app * | f_main |
app * | f_this |
std::vector< conf_dec_ptr_t > | f_subcommand_decorators |
Adds the ability to create options and subcommands that are tied to a main_app's master config.
Note that while this class is called a decorator, it does not follow the actual decorator pattern. It does, however, follow the spirit of that pattern in that it adds a capability to the CLI::App class.
Subcommands and options are tied to the main_app in slightly different ways because of the different ways in which those two CLI11 classes are used.
Subcommands are CLI::App objects, and any App can have subcommands. Therefore the collection of Apps in use in a given application can form a multi-level parent-child structure. Each parent App can have multiple children, and owns those child App objects. The children can also be parents, of course. The scarab::config_decorator for each subcommand App object is created by the parent config_decorator's add_config_subcommand() function. That decorator has a link to its App and is owned by its parent decorator.
At the top of the App hierarchy is the primary App. In Scarab, that's the main_app, which also inherits from config_decorator. So main_app is also the top of the config_decorator hierarchy.
Options, on the other hand, do not form their own hierarchy. Each App owns its options. On the Scarab side, though, even options that belong to subcommands contribute to the main_app's master config. Therefore when config_decorator::add_config_option() is used, the app_option_holder that corresponds to the new option is given directly to the main_app.
Definition at line 51 of file application.hh.
|
protected |
Definition at line 154 of file application.hh.
config_decorator | ( | main_app * | a_main, |
app * | a_this_app | ||
) |
Definition at line 21 of file application.cc.
|
virtual |
Definition at line 28 of file application.cc.
CLI::Option * add_config_flag | ( | std::string | a_name, |
std::string | a_master_config_addr, | ||
std::string | a_description = "" |
||
) |
Add a flag that gets automatically added to the master config of a main_app The flag can be passed multiple times, and the number of instances will be recorded in the config
Definition at line 323 of file application.hh.
CLI::Option* add_config_flag | ( | std::string | a_name, |
std::string | a_master_config_addr, | ||
std::string | a_description = "" |
||
) |
Add a flag that gets automatically added to the master config of a main_app This flag is recorded in the config as a boolean: false if it doesn't appear in the command line, and true if it does
CLI::Option * add_config_multi_option | ( | std::string | a_name, |
std::string | a_master_config_addr, | ||
std::string | a_description = "" |
||
) |
Add an option that gets automatically added to the master config of a main_app.
Definition at line 311 of file application.hh.
CLI::Option * add_config_option | ( | std::string | a_name, |
std::string | a_master_config_addr, | ||
std::string | a_description = "" |
||
) |
Add an option that gets automatically added to the master config of a main_app.
Definition at line 299 of file application.hh.
config_decorator * add_config_subcommand | ( | std::string | a_subcommand_name, |
std::string | a_description = "" |
||
) |
Add a subcommand that is linked to a particular main_app and can create options that modify that main_app's master config.
Definition at line 32 of file application.cc.
|
inline |
Definition at line 351 of file application.hh.
|
inline |
Definition at line 346 of file application.hh.
|
protected |
Definition at line 150 of file application.hh.
|
protected |
Definition at line 155 of file application.hh.
|
protected |
Definition at line 151 of file application.hh.