From 15ecfca2953d6a5e01d651bcfe8ce482c576fc3b Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Mon, 5 Mar 2018 14:25:48 -0500 Subject: [PATCH] Add plugin per config option in config file descriptions Now shows (for example) # Track only transactions whose scopes involve the listed accounts. Default is to track all transactions. (eosio::account_history_plugin) # filter_on_accounts = Instead of # Track only transactions whose scopes involve the listed accounts. Default is to track all transactions. # filter_on_accounts = Which makes it a little easier to determine the context of the config option and description --- application.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/application.cpp b/application.cpp index d508f3341..04771c561 100644 --- a/application.cpp +++ b/application.cpp @@ -215,11 +215,26 @@ void application::write_default_config(const bfs::path& cfg_file) { if(!bfs::exists(cfg_file.parent_path())) bfs::create_directories(cfg_file.parent_path()); + std::map option_to_plug; + for(auto& plug : plugins) { + boost::program_options::options_description plugin_cli_opts; + boost::program_options::options_description plugin_cfg_opts; + plug.second->set_program_options(plugin_cli_opts, plugin_cfg_opts); + + for(const boost::shared_ptr& opt : plugin_cfg_opts.options()) + option_to_plug[opt->long_name()] = plug.second->name(); + } + std::ofstream out_cfg( bfs::path(cfg_file).make_preferred().string()); for(const boost::shared_ptr od : my->_cfg_options.options()) { - if(!od->description().empty()) - out_cfg << "# " << od->description() << std::endl; + if(!od->description().empty()) { + out_cfg << "# " << od->description(); + std::map::iterator it; + if((it = option_to_plug.find(od->long_name())) != option_to_plug.end()) + out_cfg << " (" << it->second << ")"; + out_cfg << std::endl; + } boost::any store; if(!od->semantic()->apply_default(store)) out_cfg << "# " << od->long_name() << " = " << std::endl;