Extract a single value from a ClickHouse config key via `clickhouse extract-from-config`. Returns an empty string if the key is absent (--try flag suppresses errors).
| 239 | /// Extract a single value from a ClickHouse config key via `clickhouse extract-from-config`. |
| 240 | /// Returns an empty string if the key is absent (--try flag suppresses errors). |
| 241 | std::string extractConfigValue(const std::string & config_file, const std::string & key, bool use_users = false) |
| 242 | { |
| 243 | std::vector<std::string> args = { |
| 244 | g_clickhouse_binary, "extract-from-config", |
| 245 | "--config-file", config_file, |
| 246 | "--key", key, |
| 247 | "--try", |
| 248 | }; |
| 249 | if (use_users) |
| 250 | args.emplace_back("--users"); |
| 251 | |
| 252 | auto [code, lines] = captureCommand(args); |
| 253 | return (code == 0 && !lines.empty()) ? lines[0] : std::string{}; |
| 254 | } |
| 255 | |
| 256 | /// Extract multiple values from a ClickHouse config key (wildcard patterns return multiple lines). |
| 257 | std::vector<std::string> extractConfigValues(const std::string & config_file, const std::string & key) |
no test coverage detected