diff options
author | brgayazov <brgayazov@yandex-team.com> | 2022-09-29 23:48:49 +0300 |
---|---|---|
committer | brgayazov <brgayazov@yandex-team.com> | 2022-09-29 23:48:49 +0300 |
commit | 1ea320a0c7172119d211ab23595498b78adec6eb (patch) | |
tree | 519183593c3996390cabc1e76432da61519e28d6 | |
parent | 4401b017554fb2087f25bb1380201f2a0ac043d3 (diff) | |
download | ydb-1ea320a0c7172119d211ab23595498b78adec6eb.tar.gz |
Added option -1 to command scheme ls
4 files changed, 20 insertions, 2 deletions
diff --git a/ydb/public/lib/ydb_cli/commands/ydb_service_scheme.cpp b/ydb/public/lib/ydb_cli/commands/ydb_service_scheme.cpp index 4b8401010fb..93c38319b21 100644 --- a/ydb/public/lib/ydb_cli/commands/ydb_service_scheme.cpp +++ b/ydb/public/lib/ydb_cli/commands/ydb_service_scheme.cpp @@ -708,6 +708,8 @@ void TCommandList::Config(TConfig& config) { .StoreTrue(&AdvancedMode); config.Opts->AddCharOption('R', "List subdirectories recursively") .StoreTrue(&Recursive); + config.Opts->AddCharOption('1', "List one object per line") + .StoreTrue(&FromNewLine); AddFormats(config, { EOutputFormat::Pretty, EOutputFormat::Json }); config.SetFreeArgsMax(1); SetFreeArgTitle(0, "<path>", "Path to list"); @@ -716,6 +718,10 @@ void TCommandList::Config(TConfig& config) { void TCommandList::Parse(TConfig& config) { TClientCommand::Parse(config); ParsePath(config, 0, true); + if (AdvancedMode && FromNewLine) { + // TODO: add "consider using --format shell" + throw TMisuseException() << "Options -1 and -l are incompatible"; + } } int TCommandList::Run(TConfig& config) { @@ -723,6 +729,7 @@ int TCommandList::Run(TConfig& config) { ISchemePrinter::TSettings settings = { Path, Recursive, + FromNewLine, FillSettings(NScheme::TListDirectorySettings()), FillSettings(NTable::TDescribeTableSettings().WithTableStatistics(true)) }; diff --git a/ydb/public/lib/ydb_cli/commands/ydb_service_scheme.h b/ydb/public/lib/ydb_cli/commands/ydb_service_scheme.h index 44d036298b9..c9765a524eb 100644 --- a/ydb/public/lib/ydb_cli/commands/ydb_service_scheme.h +++ b/ydb/public/lib/ydb_cli/commands/ydb_service_scheme.h @@ -71,6 +71,7 @@ public: private: bool AdvancedMode = false; bool Recursive = false; + bool FromNewLine = false; }; class TCommandPermissions : public TClientCommandTree { diff --git a/ydb/public/lib/ydb_cli/common/scheme_printers.cpp b/ydb/public/lib/ydb_cli/common/scheme_printers.cpp index 8d84c07a1d7..18308572a98 100644 --- a/ydb/public/lib/ydb_cli/common/scheme_printers.cpp +++ b/ydb/public/lib/ydb_cli/common/scheme_printers.cpp @@ -79,8 +79,17 @@ void TDefaultSchemePrinter::PrintDirectory( Cout << (relativePath ? relativePath : "./") << ":" << Endl; } if (children.size()) { - TAdaptiveTabbedTable table(children); - Cout << table; + if (Settings.FromNewLine) { + NColorizer::TColors colors = NColorizer::AutoColors(Cout); + for (const auto& child : children) { + PrintSchemeEntry(Cout, child, colors); + Cout << Endl; + } + } + else { + TAdaptiveTabbedTable table(children); + Cout << table; + } } } diff --git a/ydb/public/lib/ydb_cli/common/scheme_printers.h b/ydb/public/lib/ydb_cli/common/scheme_printers.h index c6566154488..732bbfc8e89 100644 --- a/ydb/public/lib/ydb_cli/common/scheme_printers.h +++ b/ydb/public/lib/ydb_cli/common/scheme_printers.h @@ -13,6 +13,7 @@ public: struct TSettings { TString Path; bool Recursive; + bool FromNewLine; NScheme::TListDirectorySettings ListDirectorySettings; NTable::TDescribeTableSettings DescribeTableSettings; }; |