Changeset View
Changeset View
Standalone View
Standalone View
src/util.cpp
Show First 20 Lines • Show All 593 Lines • ▼ Show 20 Lines | |||||
* integrity of mapMultiArgs data structure | * integrity of mapMultiArgs data structure | ||||
*/ | */ | ||||
void ArgsManager::ForceSetMultiArg(const std::string &strArg, | void ArgsManager::ForceSetMultiArg(const std::string &strArg, | ||||
const std::string &strValue) { | const std::string &strValue) { | ||||
LOCK(cs_args); | LOCK(cs_args); | ||||
m_override_args[strArg].push_back(strValue); | m_override_args[strArg].push_back(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)); | |||||
} | |||||
void ArgsManager::ClearArg(const std::string &strArg) { | void ArgsManager::ClearArg(const std::string &strArg) { | ||||
LOCK(cs_args); | LOCK(cs_args); | ||||
m_override_args.erase(strArg); | m_override_args.erase(strArg); | ||||
m_config_args.erase(strArg); | m_config_args.erase(strArg); | ||||
} | } | ||||
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) { | bool HelpRequested(const ArgsManager &args) { | ||||
return args.IsArgSet("-?") || args.IsArgSet("-h") || args.IsArgSet("-help"); | return args.IsArgSet("-?") || args.IsArgSet("-h") || args.IsArgSet("-help"); | ||||
} | } | ||||
static const int screenWidth = 79; | static const int screenWidth = 79; | ||||
static const int optIndent = 2; | static const int optIndent = 2; | ||||
static const int msgIndent = 7; | static const int msgIndent = 7; | ||||
▲ Show 20 Lines • Show All 452 Lines • Show Last 20 Lines |