(self, arg: str, state: _ParsingState)
| 388 | option.process(value, state) |
| 389 | |
| 390 | def _match_short_opt(self, arg: str, state: _ParsingState) -> None: |
| 391 | stop = False |
| 392 | i = 1 |
| 393 | prefix = arg[0] |
| 394 | unknown_options = [] |
| 395 | |
| 396 | for ch in arg[1:]: |
| 397 | opt = _normalize_opt(f"{prefix}{ch}", self.ctx) |
| 398 | option = self._short_opt.get(opt) |
| 399 | i += 1 |
| 400 | |
| 401 | if not option: |
| 402 | if self.ignore_unknown_options: |
| 403 | unknown_options.append(ch) |
| 404 | continue |
| 405 | raise NoSuchOption(opt, ctx=self.ctx) |
| 406 | if option.takes_value: |
| 407 | # Any characters left in arg? Pretend they're the |
| 408 | # next arg, and stop consuming characters of arg. |
| 409 | if i < len(arg): |
| 410 | state.rargs.insert(0, arg[i:]) |
| 411 | stop = True |
| 412 | |
| 413 | value = self._get_value_from_state(opt, option, state) |
| 414 | |
| 415 | else: |
| 416 | value = UNSET |
| 417 | |
| 418 | option.process(value, state) |
| 419 | |
| 420 | if stop: |
| 421 | break |
| 422 | |
| 423 | # If we got any unknown options we recombine the string of the |
| 424 | # remaining options and re-attach the prefix, then report that |
| 425 | # to the state as new large. This way there is basic combinatorics |
| 426 | # that can be achieved while still ignoring unknown arguments. |
| 427 | if self.ignore_unknown_options and unknown_options: |
| 428 | state.largs.append(f"{prefix}{''.join(unknown_options)}") |
| 429 | |
| 430 | def _get_value_from_state( |
| 431 | self, option_name: str, option: _Option, state: _ParsingState |
no test coverage detected