diff options
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"); |