aboutsummaryrefslogtreecommitdiff
path: root/src/util.h
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2018-04-28 19:40:51 -0400
committerAndrew Chow <achow101-github@achow101.com>2018-05-30 11:27:50 -0400
commit4f8704d57f8fb2958a43534779b20201b77eecae (patch)
tree4ccb64e2e65e99726786919d6d0feecde2e26377 /src/util.h
parent174f7c80801383cde5ea514b19fb8b108b56b31c (diff)
Give an error and exit if there are unknown parameters
If an unknown option is given via either the command line args or the conf file, throw an error and exit Update tests for ArgsManager knowing args Ignore unknown options in the config file for bitcoin-cli Fix tests and bitcoin-cli to match actual options used
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/util.h b/src/util.h
index 1d318e2851..62c3f7c18b 100644
--- a/src/util.h
+++ b/src/util.h
@@ -118,8 +118,7 @@ inline bool IsSwitchChar(char c)
#endif
}
-enum class OptionsCategory
-{
+enum class OptionsCategory {
OPTIONS,
CONNECTION,
WALLET,
@@ -132,7 +131,9 @@ enum class OptionsCategory
RPC,
GUI,
COMMANDS,
- REGISTER_COMMANDS
+ REGISTER_COMMANDS,
+
+ HIDDEN // Always the last option to avoid printing these in the help
};
class ArgsManager
@@ -156,7 +157,7 @@ protected:
std::set<std::string> m_network_only_args;
std::map<OptionsCategory, std::map<std::string, Arg>> m_available_args;
- void ReadConfigStream(std::istream& stream);
+ bool ReadConfigStream(std::istream& stream, std::string& error, bool ignore_invalid_keys = false);
public:
ArgsManager();
@@ -166,8 +167,8 @@ public:
*/
void SelectConfigNetwork(const std::string& network);
- void ParseParameters(int argc, const char*const argv[]);
- void ReadConfigFiles();
+ bool ParseParameters(int argc, const char* const argv[], std::string& error);
+ bool ReadConfigFiles(std::string& error, bool ignore_invalid_keys = false);
/**
* Log warnings for options in m_section_only_args when
@@ -263,9 +264,19 @@ public:
void AddArg(const std::string& name, const std::string& help, const bool debug_only, const OptionsCategory& cat);
/**
+ * Clear available arguments
+ */
+ void ClearArgs() { m_available_args.clear(); }
+
+ /**
* Get the help string
*/
std::string GetHelpMessage();
+
+ /**
+ * Check whether we know of this arg
+ */
+ bool IsArgKnown(const std::string& key, std::string& error);
};
extern ArgsManager gArgs;