(self, action)
| 599 | return self._join_parts(parts) |
| 600 | |
| 601 | def _format_action_invocation(self, action): |
| 602 | t = self._theme |
| 603 | |
| 604 | if not action.option_strings: |
| 605 | default = self._get_default_metavar_for_positional(action) |
| 606 | return ( |
| 607 | t.action |
| 608 | + ' '.join(self._metavar_formatter(action, default)(1)) |
| 609 | + t.reset |
| 610 | ) |
| 611 | |
| 612 | else: |
| 613 | |
| 614 | def color_option_strings(strings): |
| 615 | parts = [] |
| 616 | for s in strings: |
| 617 | if self._is_long_option(s): |
| 618 | parts.append(f"{t.long_option}{s}{t.reset}") |
| 619 | else: |
| 620 | parts.append(f"{t.short_option}{s}{t.reset}") |
| 621 | return parts |
| 622 | |
| 623 | # if the Optional doesn't take a value, format is: |
| 624 | # -s, --long |
| 625 | if action.nargs == 0: |
| 626 | option_strings = color_option_strings(action.option_strings) |
| 627 | return ', '.join(option_strings) |
| 628 | |
| 629 | # if the Optional takes a value, format is: |
| 630 | # -s, --long ARGS |
| 631 | else: |
| 632 | default = self._get_default_metavar_for_optional(action) |
| 633 | option_strings = color_option_strings(action.option_strings) |
| 634 | args_string = ( |
| 635 | f"{t.label}{self._format_args(action, default)}{t.reset}" |
| 636 | ) |
| 637 | return ', '.join(option_strings) + ' ' + args_string |
| 638 | |
| 639 | def _metavar_formatter(self, action, default_metavar): |
| 640 | if action.metavar is not None: |
no test coverage detected