MCPcopy Create free account
hub / github.com/catboost/catboost / ParseOptParam

Method ParseOptParam

library/cpp/getopt/small/last_getopt_parser.cpp:171–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

169 }
170
171 bool TOptsParser::ParseOptParam(const TOpt* opt, size_t pos) {
172 Y_ASSERT(opt);
173 if (opt->GetHasArg() == NO_ARGUMENT ||
174 opt->GetHasArg() == OPTIONAL_ARGUMENT && opt->IsEqParseOnly()) {
175 return Commit(opt, nullptr, pos, 0);
176 }
177 if (opt->IsEqParseOnly()) {
178 Y_ASSERT(opt->GetHasArg() == REQUIRED_ARGUMENT);
179 throw TUsageException() << "option " << opt->ToShortString() << " requires an argument but only accepts it over =";
180 }
181 if (pos == Argc_) {
182 if (opt->GetHasArg() == REQUIRED_ARGUMENT)
183 throw TUsageException() << "option " << opt->ToShortString() << " must have arg";
184 return Commit(opt, nullptr, pos, 0);
185 }
186 const TStringBuf arg(Argv_[pos]);
187 if (!arg.StartsWith('-') || opt->GetHasArg() == REQUIRED_ARGUMENT) {
188 return Commit(opt, arg, pos + 1, 0);
189 }
190 return Commit(opt, nullptr, pos, 0);
191 }
192
193 TOptsParser::EIsOpt TOptsParser::IsOpt(const TStringBuf& arg) const {
194 EIsOpt eio = EIO_NONE;

Callers

nothing calls this directly

Calls 4

TUsageExceptionClass · 0.85
IsEqParseOnlyMethod · 0.80
ToShortStringMethod · 0.80
StartsWithMethod · 0.45

Tested by

no test coverage detected