diff options
author | tldr <tldr@yandex-team.com> | 2024-11-21 17:37:20 +0300 |
---|---|---|
committer | tldr <tldr@yandex-team.com> | 2024-11-21 17:55:22 +0300 |
commit | c8482a7c9c43883e325c2ab31b58cb62abde7eba (patch) | |
tree | ec354b3e3856cba3b385d824d4b567f1ccf58b39 /library/cpp/getopt/small/last_getopt_parser.cpp | |
parent | cafe0d9f1f5555e43c16cbb1c73375fee224eca6 (diff) | |
download | ydb-c8482a7c9c43883e325c2ab31b58cb62abde7eba.tar.gz |
[arc][getopt]fix enforcment of RequiredArgument().DisableSpaceParse()
commit_hash:9c2ada5b95be3f810d2750406d74d839bd2598ff
Diffstat (limited to 'library/cpp/getopt/small/last_getopt_parser.cpp')
-rw-r--r-- | library/cpp/getopt/small/last_getopt_parser.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/library/cpp/getopt/small/last_getopt_parser.cpp b/library/cpp/getopt/small/last_getopt_parser.cpp index 911c76f342..98c3951a1c 100644 --- a/library/cpp/getopt/small/last_getopt_parser.cpp +++ b/library/cpp/getopt/small/last_getopt_parser.cpp @@ -170,9 +170,14 @@ namespace NLastGetopt { bool TOptsParser::ParseOptParam(const TOpt* opt, size_t pos) { Y_ASSERT(opt); - if (opt->GetHasArg() == NO_ARGUMENT || opt->IsEqParseOnly()) { + if (opt->GetHasArg() == NO_ARGUMENT || + opt->GetHasArg() == OPTIONAL_ARGUMENT && opt->IsEqParseOnly()) { return Commit(opt, nullptr, pos, 0); } + if (opt->IsEqParseOnly()) { + Y_ASSERT(opt->GetHasArg() == REQUIRED_ARGUMENT); + throw TUsageException() << "option " << opt->ToShortString() << " requires an argument but only accepts it over ="; + } if (pos == Argc_) { if (opt->GetHasArg() == REQUIRED_ARGUMENT) throw TUsageException() << "option " << opt->ToShortString() << " must have arg"; |