Determine if the given parameter is an option that needs a value. :param args: List of complete args before the incomplete value. :param param: Option object being checked.
(ctx: Context, args: list[str], param: Parameter)
| 573 | |
| 574 | |
| 575 | def _is_incomplete_option(ctx: Context, args: list[str], param: Parameter) -> bool: |
| 576 | """Determine if the given parameter is an option that needs a value. |
| 577 | |
| 578 | :param args: List of complete args before the incomplete value. |
| 579 | :param param: Option object being checked. |
| 580 | """ |
| 581 | if not isinstance(param, Option): |
| 582 | return False |
| 583 | |
| 584 | if param.is_flag or param.count: |
| 585 | return False |
| 586 | |
| 587 | last_option = None |
| 588 | |
| 589 | for index, arg in enumerate(reversed(args)): |
| 590 | if index + 1 > param.nargs: |
| 591 | break |
| 592 | |
| 593 | if _start_of_option(ctx, arg): |
| 594 | last_option = arg |
| 595 | break |
| 596 | |
| 597 | return last_option is not None and last_option in param.opts |
| 598 | |
| 599 | |
| 600 | def _resolve_context( |
no test coverage detected