MCPcopy Create free account
hub / github.com/REGoth-project/REGoth / readFromConfig

Method readFromConfig

src/utils/cli.cpp:130–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128}
129
130void Flag::readFromConfig(const json& contents)
131{
132 // Choose the verbose version over the smaller one
133 std::string flag = m_VerboseFlag.empty() ? m_Flag : m_VerboseFlag;
134
135 if (contents.find(m_ConfigSection) == contents.end() || contents[m_ConfigSection].find(flag) == contents[m_ConfigSection].end())
136 {
137 // It's not there, use the default
138 m_ParsedArgs = m_DefaultValues;
139 return;
140 }
141
142 const json& jf = contents[m_ConfigSection][flag];
143
144 LogInfo() << "Reading Flag '" << flag << " = " << jf.dump() << "' from config";
145
146 // Flags can be either arrays or single entries
147 if (!jf.is_array())
148 {
149 m_ParsedArgs.clear();
150 if (jf.is_boolean())
151 {
152 m_ParsedArgs.push_back(contents[m_ConfigSection][flag] ? "1" : "0"); // Doesn't matter where exactly this ends up in the commandline, this has to be non-0 to count as "set"
153 }
154 else
155 {
156 m_ParsedArgs.push_back(contents[m_ConfigSection][flag]);
157 }
158 }
159 else
160 {
161 m_ParsedArgs = contents[m_ConfigSection][flag].get<std::vector<std::string>>();
162 }
163}
164
165void Flag::writeToConfig(json& conf)
166{

Callers 1

loadConfigFileMethod · 0.80

Calls 8

findMethod · 0.80
dumpMethod · 0.80
is_arrayMethod · 0.80
is_booleanMethod · 0.80
push_backMethod · 0.80
emptyMethod · 0.45
endMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected