| 398 | } |
| 399 | |
| 400 | void KeeperClient::initialize(Poco::Util::Application & /* self */) |
| 401 | { |
| 402 | suggest.setCompletionsCallback( |
| 403 | [&](const String & prefix, size_t /* prefix_length */) { return getCompletions(prefix); }); |
| 404 | |
| 405 | String home_path; |
| 406 | const char * home_path_cstr = getenv("HOME"); // NOLINT(concurrency-mt-unsafe) |
| 407 | if (home_path_cstr) |
| 408 | home_path = home_path_cstr; |
| 409 | |
| 410 | if (config().has("history-file")) |
| 411 | history_file = config().getString("history-file"); |
| 412 | else |
| 413 | history_file = home_path + "/.keeper-client-history"; |
| 414 | |
| 415 | if (!history_file.empty() && !fs::exists(history_file)) |
| 416 | { |
| 417 | try |
| 418 | { |
| 419 | FS::createFile(history_file); |
| 420 | } |
| 421 | catch (const ErrnoException & e) |
| 422 | { |
| 423 | if (e.getErrno() != EEXIST) |
| 424 | throw; |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | history_max_entries = config().getUInt("history-max-entries", 1000000); |
| 429 | |
| 430 | String default_log_level; |
| 431 | if (config().has("query")) |
| 432 | /// We don't want to see any information log in query mode, unless it was set explicitly |
| 433 | default_log_level = "error"; |
| 434 | else |
| 435 | default_log_level = "information"; |
| 436 | |
| 437 | Poco::Logger::root().setLevel(config().getString("log-level", default_log_level)); |
| 438 | |
| 439 | EventNotifier::init(); |
| 440 | |
| 441 | const char * env_password = getenv("CLICKHOUSE_KEEPER_PASSWORD"); // NOLINT(concurrency-mt-unsafe) |
| 442 | if (env_password && !config().has("password")) |
| 443 | config().setString("password", env_password); |
| 444 | |
| 445 | const char * env_identity = getenv("CLICKHOUSE_KEEPER_IDENTITY"); // NOLINT(concurrency-mt-unsafe) |
| 446 | if (env_identity && !config().has("identity")) |
| 447 | config().setString("identity", env_identity); |
| 448 | } |
| 449 | |
| 450 | bool KeeperClient::processQueryText(const String & text, bool is_interactive) |
| 451 | { |
nothing calls this directly
no test coverage detected