Skip to content

Commit

Permalink
Add plugin section headers to generated config.ini
Browse files Browse the repository at this point in the history
  • Loading branch information
abitmore committed Mar 9, 2019
1 parent 90ca8f2 commit 22cfa56
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
8 changes: 8 additions & 0 deletions libraries/app/config_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,13 @@ static void create_new_config_file(const fc::path& config_ini_path, const fc::pa

if( !od->description().empty() )
out_cfg << "# " << od->description() << "\n";

if( od->long_name().find("plugin-cfg-header-") == 0 )
{
out_cfg << "\n";
continue;
}

boost::any store;
if( !od->semantic()->apply_default(store) )
out_cfg << "# " << od->long_name() << " = \n";
Expand All @@ -284,6 +291,7 @@ static void create_new_config_file(const fc::path& config_ini_path, const fc::pa
}

out_cfg << "\n"
<< "# =============== logging options ===============\n"
<< "# Logging configuration is loaded from logging.ini by default.\n"
<< "# If logging.ini exists, logging configuration added in this file will be ignored.\n";
out_cfg.close();
Expand Down
11 changes: 9 additions & 2 deletions libraries/app/include/graphene/app/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,20 @@ namespace graphene { namespace app {
auto plug = std::make_shared<PluginType>();
plug->plugin_set_app(this);

boost::program_options::options_description plugin_cli_options(plug->plugin_name() + " plugin. " + plug->plugin_description() + "\nOptions"), plugin_cfg_options;
//boost::program_options::options_description plugin_cli_options("Options for plugin " + plug->plugin_name()), plugin_cfg_options;
std::string cli_plugin_desc = plug->plugin_name() + " plugin. " + plug->plugin_description() + "\nOptions";
boost::program_options::options_description plugin_cli_options( cli_plugin_desc ), plugin_cfg_options;
plug->plugin_set_program_options(plugin_cli_options, plugin_cfg_options);

if( !plugin_cli_options.options().empty() )
_cli_options.add(plugin_cli_options);

if( !plugin_cfg_options.options().empty() )
{
std::string header_name = "plugin-cfg-header-" + plug->plugin_name();
std::string header_desc = "=============== " + plug->plugin_name() + " plugin options ===============";
_cfg_options.add_options()(header_name.c_str(), header_desc.c_str());
_cfg_options.add(plugin_cfg_options);
}

add_available_plugin( plug );

Expand Down

0 comments on commit 22cfa56

Please sign in to comment.