summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2018-03-19 22:00:31 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2018-03-19 22:00:31 -0400
commit0c367e19d71e78a1e60c87c69df8bfb91192d045 (patch)
treeb28e48322fb707f5893a2af72ba3b0abd0d6cf04 /cmd2.py
parent42fbd780d2393f4a2a6e25909a0a6f3f40b596a4 (diff)
downloadcmd2-git-0c367e19d71e78a1e60c87c69df8bfb91192d045.tar.gz
Appending closing quote and space when needed
Diffstat (limited to 'cmd2.py')
-rw-r--r--cmd2.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/cmd2.py b/cmd2.py
index 5a03be7d..00ff1392 100644
--- a/cmd2.py
+++ b/cmd2.py
@@ -1531,6 +1531,20 @@ class Cmd(cmd.Cmd):
# Call the completer function
self.completion_matches = compfunc(text, line, begidx, endidx)
+ # Handle single result
+ if len(self.completion_matches) == 1:
+ str_to_append = ''
+
+ # Add a closing quote if needed
+ if allow_closing_quote and unclosed_quote:
+ str_to_append += unclosed_quote
+
+ # If we are at the end of the line, then add a space
+ if allow_appended_space and endidx == len(line):
+ str_to_append += ' '
+
+ self.completion_matches[0] = self.completion_matches[0] + str_to_append
+
else:
# Complete the command against aliases and command names
strs_to_match = list(self.aliases.keys())