| 128 | } |
| 129 | |
| 130 | void 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 | |
| 165 | void Flag::writeToConfig(json& conf) |
| 166 | { |
no test coverage detected