diff options
author | Andrew Chow <achow101-github@achow101.com> | 2018-04-28 16:54:58 -0400 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2018-05-09 12:21:05 -0400 |
commit | 4d4185a4f0e40c033a587871839a47cb3f89ee93 (patch) | |
tree | de7d02bcfe19bafb3faf0f220a35b303fbfc3ba8 /src/util.cpp | |
parent | 08c1caf863656e8c4302f0ff392772f0055760e5 (diff) |
Make gArgs aware of the arguments
gArgs knows what the available arguments are and their help. Getting
the help message is moved to gArgs and HelpMessage() is removed
Diffstat (limited to 'src/util.cpp')
-rw-r--r-- | src/util.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/util.cpp b/src/util.cpp index b8723f83c6..7dd6884f75 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -547,6 +547,55 @@ void ArgsManager::ForceSetArg(const std::string& strArg, const std::string& strV m_override_args[strArg] = {strValue}; } +void ArgsManager::AddArg(const std::string& name, const std::string& help, const bool debug_only, const OptionsCategory& cat) +{ + std::pair<OptionsCategory, std::string> key(cat, name); + assert(m_available_args.count(key) == 0); + m_available_args.emplace(key, std::pair<std::string, bool>(help, debug_only)); +} + +std::string ArgsManager::GetHelpMessage() +{ + const bool show_debug = gArgs.GetBoolArg("-help-debug", false); + + std::string usage = HelpMessageGroup(_("Options:")); + + OptionsCategory last_cat = OptionsCategory::OPTIONS; + for (auto& arg : m_available_args) { + if (arg.first.first != last_cat) { + last_cat = arg.first.first; + if (last_cat == OptionsCategory::CONNECTION) + usage += HelpMessageGroup(_("Connection options:")); + else if (last_cat == OptionsCategory::ZMQ) + usage += HelpMessageGroup(_("ZeroMQ notification options:")); + else if (last_cat == OptionsCategory::DEBUG_TEST) + usage += HelpMessageGroup(_("Debugging/Testing options:")); + else if (last_cat == OptionsCategory::NODE_RELAY) + usage += HelpMessageGroup(_("Node relay options:")); + else if (last_cat == OptionsCategory::BLOCK_CREATION) + usage += HelpMessageGroup(_("Block creation options:")); + else if (last_cat == OptionsCategory::RPC) + usage += HelpMessageGroup(_("RPC server options:")); + else if (last_cat == OptionsCategory::WALLET) + usage += HelpMessageGroup(_("Wallet options:")); + else if (last_cat == OptionsCategory::WALLET_DEBUG_TEST && show_debug) + usage += HelpMessageGroup(_("Wallet debugging/testing options:")); + else if (last_cat == OptionsCategory::CHAINPARAMS) + usage += HelpMessageGroup(_("Chain selection options:")); + else if (last_cat == OptionsCategory::GUI) + usage += HelpMessageGroup(_("UI Options:")); + else if (last_cat == OptionsCategory::COMMANDS) + usage += HelpMessageGroup(_("Commands:")); + else if (last_cat == OptionsCategory::REGISTER_COMMANDS) + usage += HelpMessageGroup(_("Register Commands:")); + } + if (show_debug || !arg.second.second) { + usage += HelpMessageOpt(arg.first.second, arg.second.first); + } + } + return usage; +} + bool HelpRequested(const ArgsManager& args) { return args.IsArgSet("-?") || args.IsArgSet("-h") || args.IsArgSet("-help"); |