Changeset View
Changeset View
Standalone View
Standalone View
src/util/system.cpp
Show First 20 Lines • Show All 477 Lines • ▼ Show 20 Lines | #endif | ||||
if (InterpretNegatedOption(key, val)) { | if (InterpretNegatedOption(key, val)) { | ||||
m_override_args[key].clear(); | m_override_args[key].clear(); | ||||
} else { | } else { | ||||
m_override_args[key].push_back(val); | m_override_args[key].push_back(val); | ||||
} | } | ||||
// Check that the arg is known | // Check that the arg is known | ||||
if (!(IsSwitchChar(key[0]) && key.size() == 1)) { | if (!(IsSwitchChar(key[0]) && key.size() == 1)) { | ||||
if (!IsArgKnown(key, error)) { | if (!IsArgKnown(key)) { | ||||
error = strprintf("Invalid parameter %s", key.c_str()); | error = strprintf("Invalid parameter %s", key.c_str()); | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
// we do not allow -includeconf from command line, so we clear it here | // we do not allow -includeconf from command line, so we clear it here | ||||
auto it = m_override_args.find("-includeconf"); | auto it = m_override_args.find("-includeconf"); | ||||
if (it != m_override_args.end()) { | if (it != m_override_args.end()) { | ||||
if (it->second.size() > 0) { | if (it->second.size() > 0) { | ||||
for (const auto &ic : it->second) { | for (const auto &ic : it->second) { | ||||
fprintf(stderr, | fprintf(stderr, | ||||
"warning: -includeconf cannot be used from " | "warning: -includeconf cannot be used from " | ||||
"commandline; ignoring -includeconf=%s\n", | "commandline; ignoring -includeconf=%s\n", | ||||
ic.c_str()); | ic.c_str()); | ||||
} | } | ||||
m_override_args.erase(it); | m_override_args.erase(it); | ||||
} | } | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
bool ArgsManager::IsArgKnown(const std::string &key, std::string &error) { | bool ArgsManager::IsArgKnown(const std::string &key) const { | ||||
size_t option_index = key.find('.'); | size_t option_index = key.find('.'); | ||||
std::string arg_no_net; | std::string arg_no_net; | ||||
if (option_index == std::string::npos) { | if (option_index == std::string::npos) { | ||||
arg_no_net = key; | arg_no_net = key; | ||||
} else { | } else { | ||||
arg_no_net = | arg_no_net = | ||||
std::string("-") + key.substr(option_index + 1, std::string::npos); | std::string("-") + key.substr(option_index + 1, std::string::npos); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 150 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
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() { | std::string ArgsManager::GetHelpMessage() const { | ||||
const bool show_debug = gArgs.GetBoolArg("-help-debug", false); | const bool show_debug = gArgs.GetBoolArg("-help-debug", false); | ||||
std::string usage = ""; | std::string usage = ""; | ||||
for (const auto &arg_map : m_available_args) { | for (const auto &arg_map : m_available_args) { | ||||
switch (arg_map.first) { | switch (arg_map.first) { | ||||
case OptionsCategory::OPTIONS: | case OptionsCategory::OPTIONS: | ||||
usage += HelpMessageGroup("Options:"); | usage += HelpMessageGroup("Options:"); | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 260 Lines • ▼ Show 20 Lines | for (const std::pair<std::string, std::string> &option : | ||||
if (InterpretNegatedOption(strKey, strValue)) { | if (InterpretNegatedOption(strKey, strValue)) { | ||||
m_config_args[strKey].clear(); | m_config_args[strKey].clear(); | ||||
} else { | } else { | ||||
m_config_args[strKey].push_back(strValue); | m_config_args[strKey].push_back(strValue); | ||||
} | } | ||||
// Check that the arg is known | // Check that the arg is known | ||||
if (!IsArgKnown(strKey, error) && !ignore_invalid_keys) { | if (!IsArgKnown(strKey) && !ignore_invalid_keys) { | ||||
error = strprintf("Invalid configuration value %s", | error = strprintf("Invalid configuration value %s", | ||||
option.first.c_str()); | option.first.c_str()); | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 392 Lines • Show Last 20 Lines |