summaryrefslogtreecommitdiff
path: root/cmd2/utils.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2019-07-15 22:49:36 -0400
committerGitHub <noreply@github.com>2019-07-15 22:49:36 -0400
commit94b424e9c41f99c6eb268c6c97f09e99a8342de8 (patch)
treebcbf724e20fed985f7d05515a10d28ba32112a68 /cmd2/utils.py
parent8109e70b0442206103fa5fe1a3af79d1851d7ec1 (diff)
parent3ad59ceffb9810b774a93448328c7c590080cc98 (diff)
downloadcmd2-git-94b424e9c41f99c6eb268c6c97f09e99a8342de8.tar.gz
Merge pull request #718 from python-cmd2/auto_completer_refactor
Auto completer refactor
Diffstat (limited to 'cmd2/utils.py')
-rw-r--r--cmd2/utils.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/cmd2/utils.py b/cmd2/utils.py
index 872c2192..7f357a6c 100644
--- a/cmd2/utils.py
+++ b/cmd2/utils.py
@@ -616,3 +616,19 @@ class RedirectionSavedState(object):
# If the command created a process to pipe to, then then is its reader
self.pipe_proc_reader = None
+
+
+# noinspection PyUnusedLocal
+def basic_complete(text: str, line: str, begidx: int, endidx: int, match_against: Iterable) -> List[str]:
+ """
+ Basic tab completion function that matches against a list of strings without considering line contents
+ or cursor position. The args required by this function are defined in the header of Pythons's cmd.py.
+
+ :param text: the string prefix we are attempting to match (all returned 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
+ :param match_against: the strings being matched against
+ :return: a list of possible tab completions
+ """
+ return [cur_match for cur_match in match_against if cur_match.startswith(text)]