| 182 | } |
| 183 | |
| 184 | std::string Flag::documentConfigText(const std::string& configText) |
| 185 | { |
| 186 | std::vector<std::string> lines = Utils::split(configText, '\n'); |
| 187 | std::vector<std::string> docLines = Utils::split(m_Desc, '\n'); |
| 188 | std::vector<std::string> actualLines; |
| 189 | std::string flag = m_VerboseFlag.empty() ? m_Flag : m_VerboseFlag; |
| 190 | |
| 191 | // Find a line with our flag |
| 192 | for (size_t i = 0; i < lines.size(); i++) |
| 193 | { |
| 194 | if (lines[i].find("\"" + flag + "\": ") != std::string::npos) |
| 195 | { |
| 196 | // This is our line! Add our desc above it |
| 197 | for (const std::string& d : docLines) |
| 198 | { |
| 199 | // Indent and prefix with # |
| 200 | std::string c = "\n"; // Add one free line between the comment and the previous line |
| 201 | c.insert(1, JSON_DUMP_INDENTATION * 2, ' '); // 2 indents because of section |
| 202 | c += "# " + d; |
| 203 | actualLines.push_back(c); |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | actualLines.push_back(lines[i]); |
| 208 | } |
| 209 | |
| 210 | // Merge lines to text again |
| 211 | std::string r; |
| 212 | for (const std::string& l : actualLines) |
| 213 | r += l + "\n"; |
| 214 | |
| 215 | return r; |
| 216 | } |
| 217 | |
| 218 | const std::string& Flag::getParam(unsigned i) |
| 219 | { |