| 11 | { |
| 12 | |
| 13 | std::optional<std::string> getClientConfigPath(const std::string & home_path) |
| 14 | { |
| 15 | std::string config_path; |
| 16 | |
| 17 | std::vector<std::string> names; |
| 18 | names.emplace_back("./clickhouse-client"); |
| 19 | |
| 20 | auto xdg_config_home = XDGBaseDirectories::getConfigurationHome(); |
| 21 | if (!xdg_config_home.empty()) |
| 22 | names.emplace_back(xdg_config_home / "config"); |
| 23 | |
| 24 | if (!home_path.empty()) |
| 25 | names.emplace_back(home_path + "/.clickhouse-client/config"); |
| 26 | |
| 27 | names.emplace_back("/etc/clickhouse-client/config"); |
| 28 | |
| 29 | for (const auto & name : names) |
| 30 | { |
| 31 | for (const auto & extension : {".xml", ".yaml", ".yml"}) |
| 32 | { |
| 33 | config_path = name + extension; |
| 34 | |
| 35 | std::error_code ec; |
| 36 | if (fs::exists(config_path, ec)) |
| 37 | return config_path; |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | return std::nullopt; |
| 42 | } |
| 43 | |
| 44 | } |
no test coverage detected