Reverse order on implicit options

This commit is contained in:
Raúl Marín 2024-11-08 11:53:46 +01:00
parent 4fb38411c1
commit 5275c0a8c4

View File

@ -109,8 +109,8 @@ void ClientApplicationBase::parseAndCheckOptions(OptionsDescription & options_de
&& !op.original_tokens[0].empty() && !op.value.empty())
{
/// Two special cases for better usability:
/// - if the option is a filesystem file, then it's likely a queries file (clickhouse repro.sql)
/// - if the option contains a whitespace, it might be a query: clickhouse "SELECT 1"
/// - if the option is a filesystem file, then it's likely a queries file (clickhouse repro.sql)
/// These are relevant for interactive usage - user-friendly, but questionable in general.
/// In case of ambiguity or for scripts, prefer using proper options.
@ -119,10 +119,10 @@ void ClientApplicationBase::parseAndCheckOptions(OptionsDescription & options_de
const char * option;
std::error_code ec;
if (std::filesystem::is_regular_file(std::filesystem::path{token}, ec))
option = "queries-file";
else if (token.contains(' '))
if (token.contains(' '))
option = "query";
else if (std::filesystem::is_regular_file(std::filesystem::path{token}, ec))
option = "queries-file";
else
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Positional option `{}` is not supported.", token);