aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/getopt/small/last_getopt_parser.cpp
diff options
context:
space:
mode:
authortldr <tldr@yandex-team.com>2024-11-21 17:37:20 +0300
committertldr <tldr@yandex-team.com>2024-11-21 17:55:22 +0300
commitc8482a7c9c43883e325c2ab31b58cb62abde7eba (patch)
treeec354b3e3856cba3b385d824d4b567f1ccf58b39 /library/cpp/getopt/small/last_getopt_parser.cpp
parentcafe0d9f1f5555e43c16cbb1c73375fee224eca6 (diff)
downloadydb-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.cpp7
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";