1#include "configReadClient.h"
2
3#include <Poco/Util/Application.h>
4#include <Poco/Util/LayeredConfiguration.h>
5#include <Poco/File.h>
6#include "ConfigProcessor.h"
7
8namespace DB
9{
10bool configReadClient(Poco::Util::LayeredConfiguration & config, const std::string & home_path)
11{
12 std::string config_path;
13 if (config.has("config-file"))
14 config_path = config.getString("config-file");
15 else if (Poco::File("./clickhouse-client.xml").exists())
16 config_path = "./clickhouse-client.xml";
17 else if (!home_path.empty() && Poco::File(home_path + "/.clickhouse-client/config.xml").exists())
18 config_path = home_path + "/.clickhouse-client/config.xml";
19 else if (Poco::File("/etc/clickhouse-client/config.xml").exists())
20 config_path = "/etc/clickhouse-client/config.xml";
21
22 if (!config_path.empty())
23 {
24 ConfigProcessor config_processor(config_path);
25 auto loaded_config = config_processor.loadConfig();
26 config.add(loaded_config.configuration);
27 return true;
28 }
29 return false;
30}
31}
32