mirror of
https://github.com/hanzoai/datastore.git
synced 2026-09-26 13:55:07 +00:00
clickhouse/ch aliases can invoke clickhouse-client if connection parameters are specified
This commit is contained in:
@@ -283,6 +283,22 @@ int main(int argc_, char ** argv_)
|
||||
}
|
||||
}
|
||||
|
||||
/// If host/port arguments are passed to clickhouse/ch shortcuts,
|
||||
/// interpret it as clickhouse-client invocation for usability.
|
||||
if (main_func == printHelp && argv.size() >= 2)
|
||||
{
|
||||
for (size_t i = 1, num_args = argv.size(); i < num_args; ++i)
|
||||
{
|
||||
if ((i + 1 < num_args && argv[i] == std::string_view("--host")) || startsWith(argv[i], "--host=")
|
||||
|| (i + 1 < num_args && argv[i] == std::string_view("--port")) || startsWith(argv[i], "--port=")
|
||||
|| startsWith(argv[i], "-h"))
|
||||
{
|
||||
main_func = mainEntryClickHouseClient;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Interpret binary without argument or with arguments starts with dash
|
||||
/// ('-') as clickhouse-local for better usability:
|
||||
///
|
||||
@@ -295,6 +311,7 @@ int main(int argc_, char ** argv_)
|
||||
///
|
||||
std::error_code ec;
|
||||
if (main_func == printHelp && !argv.empty()
|
||||
&& (argv.size() < 2 || argv[1] != std::string_view("--help"))
|
||||
&& (argv.size() == 1 || argv[1][0] == '-' || std::string_view(argv[1]).contains(' ')
|
||||
|| std::filesystem::is_regular_file(std::filesystem::path{argv[1]}, ec)))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user