add --verbose for help and suggest to use system.settings

This commit is contained in:
Yarik Briukhovetskyi 2024-04-25 17:01:34 +02:00 committed by GitHub
parent 0cc404a74c
commit a36d86f63a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 36 additions and 3 deletions

View File

@ -598,6 +598,7 @@ int mainEntryClickHouseBenchmark(int argc, char ** argv)
boost::program_options::options_description desc = createOptionsDescription("Allowed options", getTerminalWidth());
desc.add_options()
("help", "produce help message")
("verbose", "print more detailed message")
("query,q", value<std::string>()->default_value(""), "query to execute")
("concurrency,c", value<unsigned>()->default_value(1), "number of parallel queries")
("delay,d", value<double>()->default_value(1), "delay between intermediate reports in seconds (set 0 to disable reports)")
@ -629,13 +630,19 @@ int mainEntryClickHouseBenchmark(int argc, char ** argv)
boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), options);
boost::program_options::notify(options);
if (options.count("verbose"))
settings.addProgramOptions(desc);
boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), options);
boost::program_options::notify(options);
clearPasswordFromCommandLine(argc, argv);
if (options.count("help"))
{
std::cout << "Usage: " << argv[0] << " [options] < queries.txt\n";
std::cout << desc << "\n";
std::cout << "All setting parameters are documented in detail at https://clickhouse.com/docs/\n";
std::cout << "All setting parameters are documented in detail at https://clickhouse.com/docs/ or you can access them in `system.settings` table.\n";
std::cout << "\nSee also: https://clickhouse.com/docs/en/operations/utilities/clickhouse-benchmark/\n";
return 0;
}

View File

@ -923,7 +923,7 @@ void Client::printHelpMessage(const OptionsDescription & options_description)
std::cout << options_description.main_description.value() << "\n";
std::cout << options_description.external_description.value() << "\n";
std::cout << options_description.hosts_and_ports_description.value() << "\n";
std::cout << "All setting parameters are documented in detail at https://clickhouse.com/docs/\n\n";
std::cout << "All setting parameters are documented in detail at https://clickhouse.com/docs/ or you can access them in `system.settings` table.\n\n";
std::cout << "In addition, --param_name=value can be specified for substitution of parameters for parametrized queries.\n";
std::cout << "\nSee also: https://clickhouse.com/docs/en/integrations/sql-clients/cli\n";
}

View File

@ -778,7 +778,7 @@ void LocalServer::printHelpMessage([[maybe_unused]] const OptionsDescription & o
{
std::cout << getHelpHeader() << "\n";
std::cout << options_description.main_description.value() << "\n";
std::cout << "All setting parameters are documented in detail at https://clickhouse.com/docs/\n\n";
std::cout << "All setting parameters are documented in detail at https://clickhouse.com/docs/ or you can access them in `system.settings` table.\n\n";
std::cout << getHelpFooter() << "\n";
std::cout << "In addition, --param_name=value can be specified for substitution of parameters for parametrized queries.\n";
std::cout << "\nSee also: https://clickhouse.com/docs/en/operations/utilities/clickhouse-local/\n";

View File

@ -2844,6 +2844,31 @@ private:
}
void ClientBase::verboseHelpMessageIfNeeded(OptionsDescription & options_description)
{
if (config().getBool("verbose", false))
{
auto getter = [](const auto & op)
{
String op_long_name = op->long_name();
return "--" + String(op_long_name);
};
if (options_description.main_description)
{
const auto & main_options = options_description.main_description->options();
std::transform(main_options.begin(), main_options.end(), std::back_inserter(cmd_options), getter);
}
if (options_description.external_description)
{
const auto & external_options = options_description.external_description->options();
std::transform(external_options.begin(), external_options.end(), std::back_inserter(cmd_options), getter);
}
}
}
void ClientBase::parseAndCheckOptions(OptionsDescription & options_description, po::variables_map & options, Arguments & arguments)
{
if (allow_merge_tree_settings)

View File

@ -174,6 +174,7 @@ private:
String prompt() const;
void resetOutput();
void verboseHelpMessageIfNeeded(OptionsDescription & options_description);
void parseAndCheckOptions(OptionsDescription & options_description, po::variables_map & options, Arguments & arguments);
void updateSuggest(const ASTPtr & ast);