#pragma once #include "Parser.h" #include "Commands.h" #include #include #include #include #include #include #include #include namespace fs = std::filesystem; namespace DB { static const NameSet four_letter_word_commands { "ruok", "mntr", "srvr", "stat", "srst", "conf", "cons", "crst", "envi", "dirs", "isro", "wchs", "wchc", "wchp", "dump", "csnp", "lgif", "rqld", }; class KeeperClient: public Poco::Util::Application { public: KeeperClient() = default; void initialize(Poco::Util::Application & self) override; int main(const std::vector & args) override; void defineOptions(Poco::Util::OptionSet & options) override; fs::path getAbsolutePath(const String & relative) const; void askConfirmation(const String & prompt, std::function && callback); String executeFourLetterCommand(const String & command); zkutil::ZooKeeperPtr zookeeper; std::filesystem::path cwd = "/"; std::function confirmation_callback; inline static std::map commands; protected: void runInteractive(); void runInteractiveReplxx(); void runInteractiveInputStream(); bool processQueryText(const String & text); void loadCommands(std::vector && new_commands); std::vector getCompletions(const String & prefix) const; String history_file; UInt32 history_max_entries; /// Maximum number of entries in the history file. LineReader::Suggest suggest; zkutil::ZooKeeperArgs zk_args; bool ask_confirmation = true; bool waiting_confirmation = false; std::vector registered_commands_and_four_letter_words; }; }