8 #define SCARAB_API_EXPORTS 19 LOGGER(applog,
"application");
27 f_subcommand_decorators()
37 app* t_subcommand =
f_this->add_subcommand( a_subcommand_name, a_description );
50 f_global_verbosity( 1 ),
51 f_nonoption_kw_args(),
52 f_nonoption_ord_args(),
54 f_app_option_holders()
58 add_option(
"-c,--config", f_config_filename,
"Config file filename" )->check(CLI::ExistingFile);
59 add_option(
"--verbosity", f_global_verbosity,
"Global logger verosity" );
61 auto t_version_callback = [](int)
66 add_flag_function(
"-V,--version", t_version_callback,
"Print the version message and exit" );
89 f_nonoption_kw_args = t_no_parser.kw_args();
90 f_nonoption_ord_args = t_no_parser.ord_args();
94 LERROR( applog,
"Unable to parse remaining arguments: " << e.
what() );
102 LPROG( applog,
"Final configuration:\n" << f_master_config );
103 LPROG( applog,
"Ordered args:\n" << f_nonoption_ord_args );
109 LDEBUG( applog,
"first configuration stage" );
110 f_master_config.merge( f_default_config );
117 LDEBUG( applog,
"second configuration stage" );
118 if( ! f_config_filename.empty() )
121 LDEBUG( applog,
"Loading config file <" << t_config_filepath <<
"> from filename <" << f_config_filename <<
">" );
123 std::unique_ptr< param > t_config_from_file( t_translator.
read_file( t_config_filepath.string() ));
124 if( t_config_from_file == NULL )
126 throw error() <<
"[application] error parsing config file";
128 if( ! t_config_from_file->is_node() )
130 throw error() <<
"[application] configuration file must consist of an object/node";
132 f_master_config.merge( t_config_from_file->as_node() );
140 LDEBUG( applog,
"third configuration stage" );
141 f_master_config.merge( f_nonoption_kw_args );
148 std::for_each( f_app_option_holders.begin(), f_app_option_holders.end(),
149 [
this]( std::shared_ptr< app_option_holder > a_ptr ){ a_ptr->add_to_app_options(f_app_options); } );
150 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)
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.
LOGGER(applog, "application")
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.