diff options
Diffstat (limited to 'cmd2/utils.py')
-rw-r--r-- | cmd2/utils.py | 16 |
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)] |