19 LOGGER( applog,
"application" );
24 f_subcommand_decorators()
34 app* t_subcommand =
f_this->add_subcommand( a_subcommand_name, a_description );
47 f_global_verbosity( 1 ),
48 f_nonoption_kw_args(),
49 f_nonoption_ord_args(),
51 f_app_option_holders()
55 add_option(
"-c,--config", f_config_filename,
"Config file filename" )->check(CLI::ExistingFile);
56 add_option(
"--verbosity", f_global_verbosity,
"Global logger verosity" );
58 auto t_version_callback = [](int)
63 add_flag_function(
"-V,--version", t_version_callback,
"Print the version message and exit" );
86 f_nonoption_kw_args = t_no_parser.kw_args();
87 f_nonoption_ord_args = t_no_parser.ord_args();
91 LERROR( applog,
"Unable to parse remaining arguments: " << e.
what() );
99 LPROG( applog,
"Final configuration:\n" << f_master_config );
100 LPROG( applog,
"Ordered args:\n" << f_nonoption_ord_args );
106 LDEBUG( applog,
"first configuration stage" );
107 f_master_config.merge( f_default_config );
114 LDEBUG( applog,
"second configuration stage" );
115 if( ! f_config_filename.empty() )
118 LDEBUG( applog,
"Loading config file <" << t_config_filepath <<
"> from filename <" << f_config_filename <<
">" );
120 std::unique_ptr< param > t_config_from_file( t_translator.
read_file( t_config_filepath.native() ));
121 if( t_config_from_file == NULL )
123 throw error() <<
"[application] error parsing config file";
125 if( ! t_config_from_file->is_node() )
127 throw error() <<
"[application] configuration file must consist of an object/node";
129 f_master_config.merge( t_config_from_file->as_node() );
137 LDEBUG( applog,
"third configuration stage" );
138 f_master_config.merge( f_nonoption_kw_args );
145 std::for_each( f_app_option_holders.begin(), f_app_option_holders.end(),
146 [
this]( std::shared_ptr< app_option_holder > a_ptr ){ a_ptr->add_to_app_options(f_app_options); } );
147 f_master_config.merge( f_app_options );
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...
path expand_path(const string &a_path)
LOGGER(mtlog, "authentication")
config_decorator(main_app *a_main, app *a_this_app)
static version_wrapper * get_instance()
virtual const char * what() const
virtual void do_config_stage_4()
Load the application-specific options.
Contains the logger class and macros, based on Kasper's KLogger class.
virtual void do_config_stage_1()
Load default values.
virtual void do_config_stage_2()
Load the config file.
virtual ~config_decorator()
Adds the ability to create options and subcommands that are tied to a main_app's master config...
virtual void pre_callback()
void set_imp(scarab::version_semantic *a_imp)
std::vector< conf_dec_ptr_t > f_subcommand_decorators
param_ptr_t read_file(const std::string &a_filename, const param_node &a_options=param_node())
void set_version(version_semantic *a_ver)
This is a successful completion on parsing, supposed to exit.
Primary application class.
Anything that can error in Parse.
virtual void do_config_stage_3()
Load the directly-addressed non-option arguments.