| 187 | } |
| 188 | |
| 189 | void TOpts::Validate() const { |
| 190 | for (TOptsVector::const_iterator i = Opts_.begin(); i != Opts_.end(); ++i) { |
| 191 | TOpt* opt = i->Get(); |
| 192 | const TOpt::TShortNames& shortNames = opt->GetShortNames(); |
| 193 | for (auto c : shortNames) { |
| 194 | for (TOptsVector::const_iterator j = i + 1; j != Opts_.end(); ++j) { |
| 195 | TOpt* nextOpt = j->Get(); |
| 196 | if (nextOpt->CharIs(c)) |
| 197 | ythrow TConfException() << "option " |
| 198 | << NPrivate::OptToString(c) |
| 199 | << " is defined more than once"; |
| 200 | } |
| 201 | } |
| 202 | const TOpt::TLongNames& longNames = opt->GetLongNames(); |
| 203 | for (const auto& longName : longNames) { |
| 204 | for (TOptsVector::const_iterator j = i + 1; j != Opts_.end(); ++j) { |
| 205 | TOpt* nextOpt = j->Get(); |
| 206 | if (nextOpt->NameIs(longName)) |
| 207 | ythrow TConfException() << "option " |
| 208 | << NPrivate::OptToString(longName) |
| 209 | << " is defined more than once"; |
| 210 | } |
| 211 | } |
| 212 | } |
| 213 | if (FreeArgsMax_ < FreeArgsMin_) { |
| 214 | ythrow TConfException() << "FreeArgsMax must be >= FreeArgsMin"; |
| 215 | } |
| 216 | if (!FreeArgSpecs_.empty() && GetTrailingArgsIndex() > FreeArgsMax_) { |
| 217 | ythrow TConfException() << "Described args count is greater than FreeArgsMax. Either increase FreeArgsMax or remove unreachable descriptions"; |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | TOpt& TOpts::AddOption(const TOpt& option) { |
| 222 | if (option.GetShortNames().empty() && option.GetLongNames().empty()) |
no test coverage detected