summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrgayazov <[email protected]>2023-03-29 22:00:22 +0300
committerbrgayazov <[email protected]>2023-03-29 22:00:22 +0300
commitb657fafc4f4b9aaa42d9edb7f15fb287d2722b3d (patch)
tree90bd24a46fa9b84889477455bdcb72a2b672484d
parent2bcad1479a2fc68315a3373a6bad19e5d2a29ca2 (diff)
Changed the order of options in --help of yql commands
-rw-r--r--ydb/public/lib/ydb_cli/commands/ydb_service_scripting.cpp6
-rw-r--r--ydb/public/lib/ydb_cli/commands/ydb_service_table.cpp6
-rw-r--r--ydb/public/lib/ydb_cli/commands/ydb_yql.cpp6
-rw-r--r--ydb/public/lib/ydb_cli/common/parameters.cpp42
-rw-r--r--ydb/public/lib/ydb_cli/common/parameters.h3
-rw-r--r--ydb/tests/functional/ydb_cli/canondata/test_ydb_scripting.TestScriptingServiceHelp.test_help/result.output32
-rw-r--r--ydb/tests/functional/ydb_cli/canondata/test_ydb_scripting.TestScriptingServiceHelp.test_help_ex/result.output46
7 files changed, 76 insertions, 65 deletions
diff --git a/ydb/public/lib/ydb_cli/commands/ydb_service_scripting.cpp b/ydb/public/lib/ydb_cli/commands/ydb_service_scripting.cpp
index 69918afc1bf..6ccb862be07 100644
--- a/ydb/public/lib/ydb_cli/commands/ydb_service_scripting.cpp
+++ b/ydb/public/lib/ydb_cli/commands/ydb_service_scripting.cpp
@@ -29,8 +29,6 @@ void TCommandExecuteYqlScript::Config(TConfig& config) {
config.Opts->AddLongOption("explain", "Explain query").Optional().StoreTrue(&Explain);
config.Opts->AddLongOption("show-response-metadata", ResponseHeadersHelp).Optional().StoreTrue(&ShowHeaders);
- AddParametersOption(config, "script");
-
AddFormats(config, {
EOutputFormat::Pretty,
EOutputFormat::JsonUnicode,
@@ -39,6 +37,8 @@ void TCommandExecuteYqlScript::Config(TConfig& config) {
EOutputFormat::JsonBase64Array
});
+ AddParametersOption(config);
+
AddInputFormats(config, {
EOutputFormat::JsonUnicode,
EOutputFormat::JsonBase64
@@ -53,6 +53,8 @@ void TCommandExecuteYqlScript::Config(TConfig& config) {
EOutputFormat::NewlineDelimited
});
+ AddParametersStdinOption(config, "script");
+
config.SetFreeArgsNum(0);
AddCommandExamples(
diff --git a/ydb/public/lib/ydb_cli/commands/ydb_service_table.cpp b/ydb/public/lib/ydb_cli/commands/ydb_service_table.cpp
index a9129b3b277..19832aef73d 100644
--- a/ydb/public/lib/ydb_cli/commands/ydb_service_table.cpp
+++ b/ydb/public/lib/ydb_cli/commands/ydb_service_table.cpp
@@ -356,8 +356,6 @@ void TCommandExecuteQuery::Config(TConfig& config) {
config.Opts->AddLongOption('f', "file", "Path to file with query text to execute")
.RequiredArgument("PATH").StoreResult(&QueryFile);
- AddParametersOption(config, "query", "(for data & scan queries)");
-
AddFormats(config, {
EOutputFormat::Pretty,
EOutputFormat::JsonUnicode,
@@ -368,6 +366,8 @@ void TCommandExecuteQuery::Config(TConfig& config) {
EOutputFormat::Tsv
});
+ AddParametersOption(config, "(for data & scan queries)");
+
AddInputFormats(config, {
EOutputFormat::JsonUnicode,
EOutputFormat::JsonBase64
@@ -382,6 +382,8 @@ void TCommandExecuteQuery::Config(TConfig& config) {
EOutputFormat::NewlineDelimited
});
+ AddParametersStdinOption(config, "query");
+
CheckExamples(config);
config.SetFreeArgsNum(0);
diff --git a/ydb/public/lib/ydb_cli/commands/ydb_yql.cpp b/ydb/public/lib/ydb_cli/commands/ydb_yql.cpp
index 8c4622841bf..b1b3f712efe 100644
--- a/ydb/public/lib/ydb_cli/commands/ydb_yql.cpp
+++ b/ydb/public/lib/ydb_cli/commands/ydb_yql.cpp
@@ -21,8 +21,6 @@ void TCommandYql::Config(TConfig& config) {
.RequiredArgument("[String]").StoreResult(&CollectStatsMode);
config.Opts->AddLongOption('s', "script", "Text of script to execute").RequiredArgument("[String]").StoreResult(&Script);
config.Opts->AddLongOption('f', "file", "Script file").RequiredArgument("PATH").StoreResult(&ScriptFile);
-
- AddParametersOption(config, "script");
AddFormats(config, {
EOutputFormat::Pretty,
@@ -34,6 +32,8 @@ void TCommandYql::Config(TConfig& config) {
EOutputFormat::Tsv
});
+ AddParametersOption(config);
+
AddInputFormats(config, {
EOutputFormat::JsonUnicode,
EOutputFormat::JsonBase64
@@ -48,6 +48,8 @@ void TCommandYql::Config(TConfig& config) {
EOutputFormat::NewlineDelimited
});
+ AddParametersStdinOption(config, "script");
+
CheckExamples(config);
config.SetFreeArgsNum(0);
diff --git a/ydb/public/lib/ydb_cli/common/parameters.cpp b/ydb/public/lib/ydb_cli/common/parameters.cpp
index c230da7b903..e602e8885c1 100644
--- a/ydb/public/lib/ydb_cli/common/parameters.cpp
+++ b/ydb/public/lib/ydb_cli/common/parameters.cpp
@@ -75,7 +75,7 @@ void TCommandWithParameters::ParseParameters(TClientCommand::TConfig& config) {
}
}
-void TCommandWithParameters::AddParametersOption(TClientCommand::TConfig& config, const TString& requestString, const TString& clarification) {
+void TCommandWithParameters::AddParametersOption(TClientCommand::TConfig& config, const TString& clarification) {
TStringStream descr;
NColorizer::TColors colors = NColorizer::AutoColors(Cout);
descr << "Query parameter[s].";
@@ -87,27 +87,9 @@ void TCommandWithParameters::AddParametersOption(TClientCommand::TConfig& config
<< "Escaping depends on operating system.";
config.Opts->AddLongOption('p', "param", descr.Str())
.RequiredArgument("$name=value").AppendTo(&ParameterOptions);
- descr.Clear();
- descr << "Batching mode for stdin parameters processing. Available options:\n "
- << colors.BoldColor() << "iterative" << colors.OldColor()
- << "\n Executes " << requestString << " for each parameter set (exactly one execution "
- "when no framing specified in \"stdin-format\")\n "
- << colors.BoldColor() << "full" << colors.OldColor()
- << "\n Executes " << requestString << " once, with all parameter sets wrapped in json list, when EOF is reached on stdin\n "
- << colors.BoldColor() << "adaptive" << colors.OldColor()
- << "\n Executes " << requestString << " with a json list of parameter sets every time when its number reaches batch-limit, "
- "or the waiting time reaches batch-max-delay."
- "\nDefault: " << colors.CyanColor() << "\"iterative\"" << colors.OldColor() << ".";
config.Opts->AddLongOption("param-file", "File name with parameter names and values "
"in json format. You may specify this option repeatedly.")
.RequiredArgument("PATH").AppendTo(&ParameterFiles);
- config.Opts->AddLongOption("stdin-par", "Parameter name on stdin, required/applicable when stdin-format implies values only.")
- .RequiredArgument("STRING").AppendTo(&StdinParameters);
- config.Opts->AddLongOption("batch", descr.Str()).RequiredArgument("STRING").StoreResult(&BatchMode);
- config.Opts->AddLongOption("batch-limit", "Maximum size of list for adaptive batching mode").RequiredArgument("INT")
- .StoreResult(&BatchLimit).DefaultValue(1000);
- config.Opts->AddLongOption("batch-max-delay", "Maximum delay to process first item in the list for adaptive batching mode")
- .RequiredArgument("VAL").StoreResult(&BatchMaxDelay).DefaultValue(TDuration::Seconds(1));
AddOptionExamples(
"param",
@@ -132,6 +114,28 @@ void TCommandWithParameters::AddParametersOption(TClientCommand::TConfig& config
);
}
+void TCommandWithParameters::AddParametersStdinOption(TClientCommand::TConfig& config, const TString& requestString) {
+ TStringStream descr;
+ NColorizer::TColors colors = NColorizer::AutoColors(Cout);
+ descr << "Batching mode for stdin parameters processing. Available options:\n "
+ << colors.BoldColor() << "iterative" << colors.OldColor()
+ << "\n Executes " << requestString << " for each parameter set (exactly one execution "
+ "when no framing specified in \"stdin-format\")\n "
+ << colors.BoldColor() << "full" << colors.OldColor()
+ << "\n Executes " << requestString << " once, with all parameter sets wrapped in json list, when EOF is reached on stdin\n "
+ << colors.BoldColor() << "adaptive" << colors.OldColor()
+ << "\n Executes " << requestString << " with a json list of parameter sets every time when its number reaches batch-limit, "
+ "or the waiting time reaches batch-max-delay."
+ "\nDefault: " << colors.CyanColor() << "\"iterative\"" << colors.OldColor() << ".";
+ config.Opts->AddLongOption("stdin-par", "Parameter name on stdin, required/applicable when stdin-format implies values only.")
+ .RequiredArgument("STRING").AppendTo(&StdinParameters);
+ config.Opts->AddLongOption("batch", descr.Str()).RequiredArgument("STRING").StoreResult(&BatchMode);
+ config.Opts->AddLongOption("batch-limit", "Maximum size of list for adaptive batching mode").RequiredArgument("INT")
+ .StoreResult(&BatchLimit).DefaultValue(1000);
+ config.Opts->AddLongOption("batch-max-delay", "Maximum delay to process first item in the list for adaptive batching mode")
+ .RequiredArgument("VAL").StoreResult(&BatchMaxDelay).DefaultValue(TDuration::Seconds(1));
+}
+
void TCommandWithParameters::AddParams(const std::map<TString, TType>& paramTypes, EOutputFormat inputFormat, TParamsBuilder& paramBuilder) {
EBinaryStringEncoding encoding;
switch (inputFormat) {
diff --git a/ydb/public/lib/ydb_cli/common/parameters.h b/ydb/public/lib/ydb_cli/common/parameters.h
index a9065f09810..bd5ba31e776 100644
--- a/ydb/public/lib/ydb_cli/common/parameters.h
+++ b/ydb/public/lib/ydb_cli/common/parameters.h
@@ -28,7 +28,8 @@ bool IsStdinInteractive();
class TCommandWithParameters : public TCommandWithExamples {
protected:
void ParseParameters(TClientCommand::TConfig& config);
- void AddParametersOption(TClientCommand::TConfig& config, const TString& requestString, const TString& clarification = "");
+ void AddParametersOption(TClientCommand::TConfig& config, const TString& clarification = "");
+ void AddParametersStdinOption(TClientCommand::TConfig& config, const TString& requestString);
bool GetNextParams(const std::map<TString, TType>& paramTypes, EOutputFormat inputFormat, EOutputFormat encodingFormat,
EOutputFormat framingFormat, THolder<TParamsBuilder>& paramBuilder);
diff --git a/ydb/tests/functional/ydb_cli/canondata/test_ydb_scripting.TestScriptingServiceHelp.test_help/result.output b/ydb/tests/functional/ydb_cli/canondata/test_ydb_scripting.TestScriptingServiceHelp.test_help/result.output
index 55c3c2ace18..759b18df2b0 100644
--- a/ydb/tests/functional/ydb_cli/canondata/test_ydb_scripting.TestScriptingServiceHelp.test_help/result.output
+++ b/ydb/tests/functional/ydb_cli/canondata/test_ydb_scripting.TestScriptingServiceHelp.test_help/result.output
@@ -15,22 +15,6 @@ Options:
{-f|--file} PATH [Required] Script file
--explain Explain query (default: 0)
--show-response-metadata Show response metadata for ydb call (default: 0)
- {-p|--param} $name=value Query parameter[s].
- Several parameter options can be specified.
- To change input format use --input-format option.
- Escaping depends on operating system.
- --param-file PATH File name with parameter names and values in json format. You may specify this option repeatedly.
- --stdin-par STRING Parameter name on stdin, required/applicable when stdin-format implies values only.
- --batch STRING Batching mode for stdin parameters processing. Available options:
- iterative
- Executes script for each parameter set (exactly one execution when no framing specified in "stdin-format")
- full
- Executes script once, with all parameter sets wrapped in json list, when EOF is reached on stdin
- adaptive
- Executes script with a json list of parameter sets every time when its number reaches batch-limit, or the waiting time reaches batch-max-delay.
- Default: "iterative".
- --batch-limit INT Maximum size of list for adaptive batching mode (default: 1000)
- --batch-max-delay VAL Maximum delay to process first item in the list for adaptive batching mode (default: "1.000000s")
--format STRING Output format. Available options:
pretty
Human readable output
@@ -43,6 +27,11 @@ Options:
json-base64-array
Output in json format, binary strings are encoded with base64. Every resultset is a json array of rows. Every row is a separate json on a separate line.
Default: "pretty".
+ {-p|--param} $name=value Query parameter[s].
+ Several parameter options can be specified.
+ To change input format use --input-format option.
+ Escaping depends on operating system.
+ --param-file PATH File name with parameter names and values in json format. You may specify this option repeatedly.
--input-format STRING Input format. Available options:
json-unicode
Input in json format, binary strings are decoded with unicode characters
@@ -64,3 +53,14 @@ Options:
newline-delimited
Newline character delimits parameter sets on stdin and triggers processing in accordance to "batch" option
Default: "no-framing".
+ --stdin-par STRING Parameter name on stdin, required/applicable when stdin-format implies values only.
+ --batch STRING Batching mode for stdin parameters processing. Available options:
+ iterative
+ Executes script for each parameter set (exactly one execution when no framing specified in "stdin-format")
+ full
+ Executes script once, with all parameter sets wrapped in json list, when EOF is reached on stdin
+ adaptive
+ Executes script with a json list of parameter sets every time when its number reaches batch-limit, or the waiting time reaches batch-max-delay.
+ Default: "iterative".
+ --batch-limit INT Maximum size of list for adaptive batching mode (default: 1000)
+ --batch-max-delay VAL Maximum delay to process first item in the list for adaptive batching mode (default: "1.000000s")
diff --git a/ydb/tests/functional/ydb_cli/canondata/test_ydb_scripting.TestScriptingServiceHelp.test_help_ex/result.output b/ydb/tests/functional/ydb_cli/canondata/test_ydb_scripting.TestScriptingServiceHelp.test_help_ex/result.output
index fd143ce0767..65c5b43defa 100644
--- a/ydb/tests/functional/ydb_cli/canondata/test_ydb_scripting.TestScriptingServiceHelp.test_help_ex/result.output
+++ b/ydb/tests/functional/ydb_cli/canondata/test_ydb_scripting.TestScriptingServiceHelp.test_help_ex/result.output
@@ -15,6 +15,18 @@ Options:
{-f|--file} PATH [Required] Script file
--explain Explain query (default: 0)
--show-response-metadata Show response metadata for ydb call (default: 0)
+ --format STRING Output format. Available options:
+ pretty
+ Human readable output
+ json-unicode
+ Output in json format, binary strings are encoded with unicode characters. Every row is a separate json on a separate line.
+ json-unicode-array
+ Output in json format, binary strings are encoded with unicode characters. Every resultset is a json array of rows. Every row is a separate json on a separate line.
+ json-base64
+ Output in json format, binary strings are encoded with base64. Every row is a separate json on a separate line.
+ json-base64-array
+ Output in json format, binary strings are encoded with base64. Every resultset is a json array of rows. Every row is a separate json on a separate line.
+ Default: "pretty".
{-p|--param} $name=value Query parameter[s].
Several parameter options can be specified.
To change input format use --input-format option.
@@ -32,29 +44,6 @@ Options:
How to pass in linux: --param '$values=[{"key":1,"value":"one"},{"key":2,"value":"two"}]'
--param-file PATH File name with parameter names and values in json format. You may specify this option repeatedly.
- --stdin-par STRING Parameter name on stdin, required/applicable when stdin-format implies values only.
- --batch STRING Batching mode for stdin parameters processing. Available options:
- iterative
- Executes script for each parameter set (exactly one execution when no framing specified in "stdin-format")
- full
- Executes script once, with all parameter sets wrapped in json list, when EOF is reached on stdin
- adaptive
- Executes script with a json list of parameter sets every time when its number reaches batch-limit, or the waiting time reaches batch-max-delay.
- Default: "iterative".
- --batch-limit INT Maximum size of list for adaptive batching mode (default: 1000)
- --batch-max-delay VAL Maximum delay to process first item in the list for adaptive batching mode (default: "1.000000s")
- --format STRING Output format. Available options:
- pretty
- Human readable output
- json-unicode
- Output in json format, binary strings are encoded with unicode characters. Every row is a separate json on a separate line.
- json-unicode-array
- Output in json format, binary strings are encoded with unicode characters. Every resultset is a json array of rows. Every row is a separate json on a separate line.
- json-base64
- Output in json format, binary strings are encoded with base64. Every row is a separate json on a separate line.
- json-base64-array
- Output in json format, binary strings are encoded with base64. Every resultset is a json array of rows. Every row is a separate json on a separate line.
- Default: "pretty".
--input-format STRING Input format. Available options:
json-unicode
Input in json format, binary strings are decoded with unicode characters
@@ -76,6 +65,17 @@ Options:
newline-delimited
Newline character delimits parameter sets on stdin and triggers processing in accordance to "batch" option
Default: "no-framing".
+ --stdin-par STRING Parameter name on stdin, required/applicable when stdin-format implies values only.
+ --batch STRING Batching mode for stdin parameters processing. Available options:
+ iterative
+ Executes script for each parameter set (exactly one execution when no framing specified in "stdin-format")
+ full
+ Executes script once, with all parameter sets wrapped in json list, when EOF is reached on stdin
+ adaptive
+ Executes script with a json list of parameter sets every time when its number reaches batch-limit, or the waiting time reaches batch-max-delay.
+ Default: "iterative".
+ --batch-limit INT Maximum size of list for adaptive batching mode (default: 1000)
+ --batch-max-delay VAL Maximum delay to process first item in the list for adaptive batching mode (default: "1.000000s")
Examples:
1) Execute script text