Skip to content

Commit 265c1b5

Browse files
committed
Add Flags enum to ArgsManager
1 parent e0d187d commit 265c1b5

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/util/system.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ void ArgsManager::AddArg(const std::string& name, const std::string& help, const
549549

550550
LOCK(cs_args);
551551
std::map<std::string, Arg>& arg_map = m_available_args[cat];
552-
auto ret = arg_map.emplace(name.substr(0, eq_index), Arg(name.substr(eq_index, name.size() - eq_index), help, debug_only));
552+
auto ret = arg_map.emplace(name.substr(0, eq_index), Arg{name.substr(eq_index, name.size() - eq_index), help, ArgsManager::NONE, debug_only});
553553
assert(ret.second); // Make sure an insertion actually happened
554554
}
555555

src/util/system.h

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,32 @@ struct SectionInfo
127127

128128
class ArgsManager
129129
{
130+
public:
131+
enum Flags {
132+
NONE = 0x00,
133+
// Boolean options can accept negation syntax -noOPTION or -noOPTION=1
134+
ALLOW_BOOL = 0x01,
135+
ALLOW_INT = 0x02,
136+
ALLOW_STRING = 0x04,
137+
ALLOW_ANY = ALLOW_BOOL | ALLOW_INT | ALLOW_STRING,
138+
DEBUG_ONLY = 0x100,
139+
/* Some options would cause cross-contamination if values for
140+
* mainnet were used while running on regtest/testnet (or vice-versa).
141+
* Setting them as NETWORK_ONLY ensures that sharing a config file
142+
* between mainnet and regtest/testnet won't cause problems due to these
143+
* parameters by accident. */
144+
NETWORK_ONLY = 0x200,
145+
};
146+
130147
protected:
131148
friend class ArgsManagerHelper;
132149

133150
struct Arg
134151
{
135152
std::string m_help_param;
136153
std::string m_help_text;
154+
unsigned int m_flags;
137155
bool m_debug_only;
138-
139-
Arg(const std::string& help_param, const std::string& help_text, bool debug_only) : m_help_param(help_param), m_help_text(help_text), m_debug_only(debug_only) {};
140156
};
141157

142158
mutable CCriticalSection cs_args;

0 commit comments

Comments
 (0)