Changeset View
Changeset View
Standalone View
Standalone View
src/util/system.cpp
Show First 20 Lines • Show All 621 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
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, | void ArgsManager::AddArg(const std::string &name, const std::string &help, | ||||
unsigned int flags, const bool debug_only, | unsigned int flags, const OptionsCategory &cat) { | ||||
const OptionsCategory &cat) { | |||||
// Split arg name from its help param | // Split arg name from its help param | ||||
size_t eq_index = name.find('='); | size_t eq_index = name.find('='); | ||||
if (eq_index == std::string::npos) { | if (eq_index == std::string::npos) { | ||||
eq_index = name.size(); | eq_index = name.size(); | ||||
} | } | ||||
LOCK(cs_args); | LOCK(cs_args); | ||||
std::map<std::string, Arg> &arg_map = m_available_args[cat]; | std::map<std::string, Arg> &arg_map = m_available_args[cat]; | ||||
auto ret = | auto ret = arg_map.emplace( | ||||
arg_map.emplace(name.substr(0, eq_index), | name.substr(0, eq_index), | ||||
Arg{name.substr(eq_index, name.size() - eq_index), help, | Arg{name.substr(eq_index, name.size() - eq_index), help, flags, false}); | ||||
ArgsManager::NONE, debug_only}); | |||||
// Make sure an insertion actually happened. | // Make sure an insertion actually happened. | ||||
assert(ret.second); | assert(ret.second); | ||||
} | } | ||||
void ArgsManager::AddHiddenArgs(const std::vector<std::string> &names) { | void ArgsManager::AddHiddenArgs(const std::vector<std::string> &names) { | ||||
for (const std::string &name : names) { | for (const std::string &name : names) { | ||||
AddArg(name, "", ArgsManager::ALLOW_ANY, false, | AddArg(name, "", ArgsManager::ALLOW_ANY, OptionsCategory::HIDDEN); | ||||
OptionsCategory::HIDDEN); | |||||
} | } | ||||
} | } | ||||
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); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | for (const auto &arg_map : m_available_args) { | ||||
} | } | ||||
// When we get to the hidden options, stop | // When we get to the hidden options, stop | ||||
if (arg_map.first == OptionsCategory::HIDDEN) { | if (arg_map.first == OptionsCategory::HIDDEN) { | ||||
break; | break; | ||||
} | } | ||||
for (const auto &arg : arg_map.second) { | for (const auto &arg : arg_map.second) { | ||||
if (show_debug || !arg.second.m_debug_only) { | if (show_debug || !(arg.second.m_flags & ArgsManager::DEBUG_ONLY)) { | ||||
std::string name; | std::string name; | ||||
if (arg.second.m_help_param.empty()) { | if (arg.second.m_help_param.empty()) { | ||||
name = arg.first; | name = arg.first; | ||||
} else { | } else { | ||||
name = arg.first + arg.second.m_help_param; | name = arg.first + arg.second.m_help_param; | ||||
} | } | ||||
usage += HelpMessageOpt(name, arg.second.m_help_text); | usage += HelpMessageOpt(name, arg.second.m_help_text); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 661 Lines • Show Last 20 Lines |