MCPcopy Index your code
hub / github.com/python-cmd2/cmd2 / complete_help_subcommands

Method complete_help_subcommands

cmd2/cmd2.py:4218–4234  ·  view source on GitHub ↗

Completes the subcommands argument of help.

(
        self, text: str, line: str, begidx: int, endidx: int, arg_tokens: Mapping[str, Sequence[str]]
    )

Source from the content-addressed store, hash-verified

4216 return self.basic_complete(text, line, begidx, endidx, strs_to_match)
4217
4218 def complete_help_subcommands(
4219 self, text: str, line: str, begidx: int, endidx: int, arg_tokens: Mapping[str, Sequence[str]]
4220 ) -> Completions:
4221 """Completes the subcommands argument of help."""
4222 # Make sure we have a command whose subcommands we will complete
4223 command = arg_tokens["command"][0]
4224 if not command:
4225 return Completions()
4226
4227 # Check if this command uses argparse
4228 if (command_func := self.get_command_func(command)) is None or (
4229 argparser := self.command_parsers.get(command_func)
4230 ) is None:
4231 return Completions()
4232
4233 completer = argparse_completer.DEFAULT_AP_COMPLETER(argparser, self)
4234 return completer.complete_subcommand_help(text, line, begidx, endidx, arg_tokens["subcommands"])
4235
4236 def _build_command_info(self) -> tuple[dict[str, list[str]], list[str]]:
4237 """Categorizes and sorts visible commands and help topics for display.

Callers

nothing calls this directly

Calls 4

get_command_funcMethod · 0.95
CompletionsClass · 0.85
getMethod · 0.45

Tested by

no test coverage detected