Supports cmd2's help command in the printing of help text. :param tokens: arguments passed to help command :param file: optional file object where the argparse should write help text If not supplied, argparse will write to sys.stdout.
(self, tokens: Sequence[str], file: IO[str] | None = None)
| 679 | return Completions() |
| 680 | |
| 681 | def print_help(self, tokens: Sequence[str], file: IO[str] | None = None) -> None: |
| 682 | """Supports cmd2's help command in the printing of help text. |
| 683 | |
| 684 | :param tokens: arguments passed to help command |
| 685 | :param file: optional file object where the argparse should write help text |
| 686 | If not supplied, argparse will write to sys.stdout. |
| 687 | """ |
| 688 | # If our parser has subcommands, we must examine the tokens and check if they are subcommands. |
| 689 | # If so, we will let the subcommand's parser handle the rest of the tokens via another ArgparseCompleter. |
| 690 | if tokens and self._subcommand_action is not None: |
| 691 | parser = self._subcommand_action.choices.get(tokens[0]) |
| 692 | if parser is not None: |
| 693 | completer_type = self._cmd2_app._determine_ap_completer_type(parser) |
| 694 | completer = completer_type(parser, self._cmd2_app) |
| 695 | completer.print_help(tokens[1:], file) |
| 696 | return |
| 697 | self._parser.print_help(file) |
| 698 | |
| 699 | def _choices_to_items(self, arg_state: _ArgumentState) -> list[CompletionItem]: |
| 700 | """Convert choices from action to list of CompletionItems.""" |
nothing calls this directly
no test coverage detected