Add list of hosts reading

This commit is contained in:
DF5HSE 2021-11-01 19:06:23 +03:00
parent e3de3889e3
commit f6d50f6fd3
3 changed files with 5 additions and 3 deletions

View File

@ -481,6 +481,7 @@ catch (...)
void Client::connect()
{
config().setString("host", hosts[0]);
connection_parameters = ConnectionParameters(config());
if (is_interactive)
@ -966,7 +967,7 @@ void Client::addOptions(OptionsDescription & options_description)
/// Main commandline options related to client functionality and all parameters from Settings.
options_description.main_description->add_options()
("config,c", po::value<std::string>(), "config-file path (another shorthand)")
("host,h", po::value<std::string>()->default_value("localhost"), "server host")
("host,h", po::value<std::vector<std::string>>()->multitoken()->default_value({"localhost"}, "localhost"), "list of server hosts")
("port", po::value<int>()->default_value(9000), "server port")
("secure,s", "Use TLS connection")
("user,u", po::value<std::string>()->default_value("default"), "user")
@ -1075,7 +1076,7 @@ void Client::processOptions(const OptionsDescription & options_description,
if (options.count("config"))
config().setString("config-file", options["config"].as<std::string>());
if (options.count("host") && !options["host"].defaulted())
config().setString("host", options["host"].as<std::string>());
hosts = options["host"].as<std::vector<std::string>>();
if (options.count("interleave-queries-file"))
interleave_queries_files = options["interleave-queries-file"].as<std::vector<std::string>>();
if (options.count("port") && !options["port"].defaulted())

View File

@ -29,6 +29,7 @@ protected:
const std::vector<Arguments> & external_tables_arguments) override;
void processConfig() override;
std::vector<String> hosts{};
private:
void printChangedSettings() const;
std::vector<String> loadWarningMessages();

View File

@ -1869,7 +1869,7 @@ void ClientBase::init(int argc, char ** argv)
/// Output of help message.
if (options.count("help")
|| (options.count("host") && options["host"].as<std::string>() == "elp")) /// If user writes -help instead of --help.
|| (options.count("host") && options["host"].as<std::vector<std::string>>()[0] == "elp")) /// If user writes -help instead of --help.
{
printHelpMessage(options_description);
exit(0);