(self, action)
| 576 | return self._join_parts(parts) |
| 577 | |
| 578 | def _format_action_invocation(self, action): |
| 579 | t = self._theme |
| 580 | |
| 581 | if not action.option_strings: |
| 582 | default = self._get_default_metavar_for_positional(action) |
| 583 | return ( |
| 584 | t.action |
| 585 | + ' '.join(self._metavar_formatter(action, default)(1)) |
| 586 | + t.reset |
| 587 | ) |
| 588 | |
| 589 | else: |
| 590 | |
| 591 | def color_option_strings(strings): |
| 592 | parts = [] |
| 593 | for s in strings: |
| 594 | if self._is_long_option(s): |
| 595 | parts.append(f"{t.long_option}{s}{t.reset}") |
| 596 | else: |
| 597 | parts.append(f"{t.short_option}{s}{t.reset}") |
| 598 | return parts |
| 599 | |
| 600 | # if the Optional doesn't take a value, format is: |
| 601 | # -s, --long |
| 602 | if action.nargs == 0: |
| 603 | option_strings = color_option_strings(action.option_strings) |
| 604 | return ', '.join(option_strings) |
| 605 | |
| 606 | # if the Optional takes a value, format is: |
| 607 | # -s, --long ARGS |
| 608 | else: |
| 609 | default = self._get_default_metavar_for_optional(action) |
| 610 | option_strings = color_option_strings(action.option_strings) |
| 611 | args_string = ( |
| 612 | f"{t.label}{self._format_args(action, default)}{t.reset}" |
| 613 | ) |
| 614 | return ', '.join(option_strings) + ' ' + args_string |
| 615 | |
| 616 | def _metavar_formatter(self, action, default_metavar): |
| 617 | if action.metavar is not None: |
no test coverage detected