Skip to content

Commit a902648

Browse files
authored
Hide deprecated operation kinds (#6407)
1 parent cc81c7e commit a902648

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

ydb/public/lib/ydb_cli/commands/ydb_service_operation.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ void TCommandListOperations::InitializeKindToHandler(TConfig& config) {
140140
{"scriptexec", &ListOperations<NQuery::TScriptExecutionOperation>},
141141
};
142142
if (config.UseExportToYt) {
143-
KindToHandler.emplace("export", &ListOperations<NExport::TExportToYtResponse>); // deprecated
143+
KindToHandler.emplace("export", THandlerWrapper(&ListOperations<NExport::TExportToYtResponse>, true)); // deprecated
144144
KindToHandler.emplace("export/yt", &ListOperations<NExport::TExportToYtResponse>);
145145
}
146146
}
@@ -149,11 +149,14 @@ TString TCommandListOperations::KindChoices() {
149149
TStringBuilder help;
150150

151151
bool first = true;
152-
for (const auto& kv : KindToHandler) {
152+
for (const auto& [kind, handler] : KindToHandler) {
153+
if (handler.Hidden) {
154+
continue;
155+
}
153156
if (!first) {
154157
help << ", ";
155158
}
156-
help << kv.first;
159+
help << kind;
157160
first = false;
158161
}
159162

ydb/public/lib/ydb_cli/commands/ydb_service_operation.h

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,23 @@ class TCommandForgetOperation : public TCommandWithOperationId {
5151
class TCommandListOperations : public TYdbCommand,
5252
public TCommandWithFormat {
5353

54-
using THandler = std::function<void(NOperation::TOperationClient&, ui64, const TString&, EOutputFormat)>;
54+
struct THandlerWrapper {
55+
using THandler = std::function<void(NOperation::TOperationClient&, ui64, const TString&, EOutputFormat)>;
56+
57+
THandler Handler;
58+
bool Hidden;
59+
60+
template <typename T>
61+
THandlerWrapper(T&& handler, bool hidden = false)
62+
: Handler(std::forward<T>(handler))
63+
, Hidden(hidden)
64+
{}
65+
66+
template <typename... Args>
67+
auto operator()(Args&&... args) {
68+
return Handler(std::forward<Args>(args)...);
69+
}
70+
};
5571

5672
void InitializeKindToHandler(TConfig& config);
5773
TString KindChoices();
@@ -66,7 +82,7 @@ class TCommandListOperations : public TYdbCommand,
6682
TString Kind;
6783
ui64 PageSize = 0;
6884
TString PageToken;
69-
THashMap<TString, THandler> KindToHandler;
85+
THashMap<TString, THandlerWrapper> KindToHandler;
7086
};
7187

7288
}

0 commit comments

Comments
 (0)