cmd2.argparse_completer¶
This module defines the ArgparseCompleter class which provides argparse-based tab completion to cmd2 apps. See the header of argparse_custom.py for instructions on how to use these features.
-
class
cmd2.argparse_completer.
ArgparseCompleter
(parser: argparse.ArgumentParser, cmd2_app: cmd2.cmd2.Cmd, *, parent_tokens: Optional[Dict[str, List[str]]] = None)¶ Automatic command line tab completion based on argparse parameters
-
complete_command
(tokens: List[str], text: str, line: str, begidx: int, endidx: int) → List[str]¶ Complete the command using the argparse metadata and provided argument dictionary :raises: CompletionError for various types of tab completion errors
-
complete_subcommand_help
(tokens: List[str], text: str, line: str, begidx: int, endidx: int) → List[str]¶ Supports cmd2’s help command in the completion of subcommand names :param tokens: command line tokens :param text: the string prefix we are attempting to match (all matches must begin with it) :param line: the current input line with leading whitespace removed :param begidx: the beginning index of the prefix text :param endidx: the ending index of the prefix text :return: List of subcommand completions
-
format_help
(tokens: List[str]) → str¶ Supports cmd2’s help command in the retrieval of help text :param tokens: command line tokens :return: help text of the command being queried
-