| 257 | } |
| 258 | |
| 259 | bool TOptsParser::DoNext() { |
| 260 | Y_ASSERT(Pos_ <= Argc_); |
| 261 | |
| 262 | if (Pos_ == Argc_) |
| 263 | return CommitEndOfOptions(Pos_); |
| 264 | |
| 265 | if (GotMinusMinus_ && Opts_->ArgPermutation_ == RETURN_IN_ORDER) { |
| 266 | Y_ASSERT(Sop_ == 0); |
| 267 | return Commit(nullptr, Argv_[Pos_], Pos_ + 1, 0); |
| 268 | } |
| 269 | |
| 270 | if (Sop_ > 0) |
| 271 | return ParseShortOptWithinArg(Pos_, Sop_); |
| 272 | |
| 273 | size_t pos = Pos_; |
| 274 | const TStringBuf arg(Argv_[pos]); |
| 275 | if (EIO_NONE != IsOpt(arg)) { |
| 276 | return ParseOptArg(pos); |
| 277 | } else if (arg == "--") { |
| 278 | if (Opts_->ArgPermutation_ == RETURN_IN_ORDER) { |
| 279 | pos += 1; |
| 280 | if (pos == Argc_) |
| 281 | return CommitEndOfOptions(pos); |
| 282 | GotMinusMinus_ = true; |
| 283 | return Commit(nullptr, Argv_[pos], pos + 1, 0); |
| 284 | } else { |
| 285 | return CommitEndOfOptions(pos + 1); |
| 286 | } |
| 287 | } else if (Opts_->ArgPermutation_ == RETURN_IN_ORDER) { |
| 288 | return Commit(nullptr, arg, pos + 1, 0); |
| 289 | } else if (Opts_->ArgPermutation_ == REQUIRE_ORDER) { |
| 290 | return CommitEndOfOptions(Pos_); |
| 291 | } else { |
| 292 | return ParseWithPermutation(); |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | bool TOptsParser::Next() { |
| 297 | bool r = false; |