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

Method Finish

library/cpp/getopt/small/last_getopt_parser.cpp:336–384  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

334 }
335
336 void TOptsParser::Finish() {
337 const TOpts::TOptsVector& optvec = Opts_->Opts_;
338 if (optvec.size() == OptsSeen_.size())
339 return;
340
341 TVector<TString> missingLong;
342 TVector<char> missingShort;
343
344 TOpts::TOptsVector::const_iterator it;
345 for (it = optvec.begin(); it != optvec.end(); ++it) {
346 const TOpt* opt = (*it).Get();
347 if (nullptr == opt)
348 continue;
349 if (OptsSeen_.contains(opt))
350 continue;
351
352 if (opt->IsRequired()) {
353 const TOpt::TLongNames& optnames = opt->GetLongNames();
354 if (!optnames.empty())
355 missingLong.push_back(optnames[0]);
356 else {
357 const char ch = opt->GetCharOr0();
358 if (0 != ch)
359 missingShort.push_back(ch);
360 }
361 continue;
362 }
363
364 if (opt->HasDefaultValue())
365 OptsDefault_.push_back(opt);
366 }
367
368 // also indicates subsequent options, if any, haven't been seen actually
369 OptsSeen_.clear();
370
371 const size_t nmissing = missingLong.size() + missingShort.size();
372 if (0 == nmissing)
373 return;
374
375 TUsageException usage;
376 usage << "The following option";
377 usage << ((1 == nmissing) ? " is" : "s are");
378 usage << " required:";
379 for (size_t i = 0; i != missingLong.size(); ++i)
380 usage << " --" << missingLong[i];
381 for (size_t i = 0; i != missingShort.size(); ++i)
382 usage << " -" << missingShort[i];
383 throw usage; // don't need lineinfo, just the message
384 }
385
386 void TOptsParser::PrintUsage(IOutputStream& os, const NColorizer::TColors& colors) const {
387 Opts_->PrintUsage(ProgramName(), os, colors);

Callers

nothing calls this directly

Calls 11

GetCharOr0Method · 0.80
HasDefaultValueMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
GetMethod · 0.45
containsMethod · 0.45
IsRequiredMethod · 0.45
emptyMethod · 0.45
push_backMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected