Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ydb/public/lib/ydb_cli/common/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ int TClientCommand::Process(TConfig& config) {
}

void TClientCommand::SaveParseResult(TConfig& config) {
ParseResult = std::make_shared<NLastGetopt::TOptsParseResult>(config.Opts, config.ArgC, config.ArgV);
ParseResult = std::make_shared<TCommandOptsParseResult>(config.Opts, config.ArgC, config.ArgV);
}

void TClientCommand::Prepare(TConfig& config) {
Expand Down
31 changes: 30 additions & 1 deletion ydb/public/lib/ydb_cli/common/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,36 @@ class TClientCommand {
}
};

class TOptsParseOneLevelResult : public NLastGetopt::TOptsParseResult {
class TCommandOptsParseResult: public NLastGetopt::TOptsParseResult {
public:
TCommandOptsParseResult(const NLastGetopt::TOpts* options, int argc, const char* argv[]) {
Init(options, argc, argv);
}
TCommandOptsParseResult(const NLastGetopt::TOpts* options, int argc, char* argv[]) {
Init(options, argc, const_cast<const char**>(argv));
}
virtual ~TCommandOptsParseResult() = default;

void HandleError() const override {
if (ThrowOnParseError) {
throw;
}
NLastGetopt::TOptsParseResult::HandleError();
}

protected:
TCommandOptsParseResult() = default;

void Init(const NLastGetopt::TOpts* options, int argc, const char* argv[]) {
ThrowOnParseError = options->HasLongOption("throw-on-parse-error");
NLastGetopt::TOptsParseResult::Init(options, argc, argv);
}

private:
bool ThrowOnParseError = false;
};

class TOptsParseOneLevelResult : public TCommandOptsParseResult {
public:
TOptsParseOneLevelResult(TConfig& config);
};
Expand Down
Loading