diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-09-13 16:23:35 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-09-13 16:23:35 -0400 |
commit | d6643affac0ebf963bfcd9c6fa5ac92cd9bd5cf4 (patch) | |
tree | bd83525fbb5107e3e0fa66ea70ea94e8dc783060 /cmd2/cmd2.py | |
parent | 294d911f3625e8c6f97937cdce964a2ce340aecd (diff) | |
download | cmd2-git-d6643affac0ebf963bfcd9c6fa5ac92cd9bd5cf4.tar.gz |
Change parsed_args to arg_tokens
Including the token being completed in arg_tokens
Diffstat (limited to 'cmd2/cmd2.py')
-rwxr-xr-x | cmd2/cmd2.py | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index 900a4c75..f859ad64 100755 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -2669,31 +2669,26 @@ class Cmd(cmd.Cmd): return utils.basic_complete(text, line, begidx, endidx, strs_to_match) def complete_help_subcommand(self, text: str, line: str, begidx: int, endidx: int, - parsed_args: argparse.Namespace) -> List[str]: + arg_tokens: argparse.Namespace) -> List[str]: """Completes the subcommand argument of help""" # Make sure we have a command whose subcommands we will complete - parsed_args.command = parsed_args.command[0] - if not parsed_args.command: + command = arg_tokens.command[0] + if not command: return [] # Check if this command uses argparse - func = self.cmd_func(parsed_args.command) + func = self.cmd_func(command) argparser = getattr(func, CMD_ATTR_ARGPARSER, None) if func is None or argparser is None: return [] - # Get all tokens through the one being completed - tokens, _ = self.tokens_for_completion(line, begidx, endidx) - if not tokens: - return [] - - # Get the index of the command - cmd_index = tokens.index(parsed_args.command) + # Combine the command and its subcommand tokens for the AutoCompleter + tokens = [command] + arg_tokens.subcommand from .argparse_completer import AutoCompleter completer = AutoCompleter(argparser, self) - return completer.complete_subcommand_help(tokens[cmd_index:], text, line, begidx, endidx) + return completer.complete_subcommand_help(tokens, text, line, begidx, endidx) help_parser = Cmd2ArgumentParser(description="List available commands or provide " "detailed help for a specific command") |