summaryrefslogtreecommitdiff
path: root/cmd2
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2019-06-23 21:03:04 -0400
committerTodd Leonhardt <todd.leonhardt@gmail.com>2019-06-23 21:03:04 -0400
commiteb1936e568a2ca4817ab0cd640220a5bc355e226 (patch)
tree86b162f79663f70cbe88e64deb4cecb93106ba68 /cmd2
parent652122f3c9907a652a9c3a14581bb2aef90bc996 (diff)
downloadcmd2-git-eb1936e568a2ca4817ab0cd640220a5bc355e226.tar.gz
Made tokens_for_completion() method public since a couple of our examples use it
Diffstat (limited to 'cmd2')
-rw-r--r--cmd2/cmd2.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index d44e6df4..e5c2ac44 100644
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -724,7 +724,7 @@ class Cmd(cmd.Cmd):
# noinspection PyUnresolvedReferences
readline.rl.mode._display_completions = self._display_matches_pyreadline
- def _tokens_for_completion(self, line: str, begidx: int, endidx: int) -> Tuple[List[str], List[str]]:
+ def tokens_for_completion(self, line: str, begidx: int, endidx: int) -> Tuple[List[str], List[str]]:
"""
Used by tab completion functions to get all tokens through the one being completed
:param line: the current input line with leading whitespace removed
@@ -938,7 +938,7 @@ class Cmd(cmd.Cmd):
:return: a list of possible tab completions
"""
# Get all tokens through the one being completed
- tokens, _ = self._tokens_for_completion(line, begidx, endidx)
+ tokens, _ = self.tokens_for_completion(line, begidx, endidx)
if not tokens:
return []
@@ -980,7 +980,7 @@ class Cmd(cmd.Cmd):
:return: a list of possible tab completions
"""
# Get all tokens through the one being completed
- tokens, _ = self._tokens_for_completion(line, begidx, endidx)
+ tokens, _ = self.tokens_for_completion(line, begidx, endidx)
if not tokens:
return []
@@ -1192,7 +1192,7 @@ class Cmd(cmd.Cmd):
# Get all tokens through the one being completed. We want the raw tokens
# so we can tell if redirection strings are quoted and ignore them.
- _, raw_tokens = self._tokens_for_completion(line, begidx, endidx)
+ _, raw_tokens = self.tokens_for_completion(line, begidx, endidx)
if not raw_tokens:
return []
@@ -1397,7 +1397,7 @@ class Cmd(cmd.Cmd):
line = expanded_line
# Get all tokens through the one being completed
- tokens, raw_tokens = self._tokens_for_completion(line, begidx, endidx)
+ tokens, raw_tokens = self.tokens_for_completion(line, begidx, endidx)
# Check if we either had a parsing error or are trying to complete the command token
# The latter can happen if " or ' was entered as the command
@@ -1570,7 +1570,7 @@ class Cmd(cmd.Cmd):
"""Default completion function for argparse commands."""
completer = AutoCompleter(argparser, self)
- tokens, _ = self._tokens_for_completion(line, begidx, endidx)
+ tokens, _ = self.tokens_for_completion(line, begidx, endidx)
if not tokens:
return []
@@ -2607,7 +2607,7 @@ class Cmd(cmd.Cmd):
"""Completes the subcommand argument of help"""
# Get all tokens through the one being completed
- tokens, _ = self._tokens_for_completion(line, begidx, endidx)
+ tokens, _ = self.tokens_for_completion(line, begidx, endidx)
if not tokens:
return []