Skip to content

Commit 64b3a88

Browse files
committed
Abbreviations are no longer accepted for multiline commands
Due to the way the parsing logic works for multiline commands, abbreviations didn't function properly with mutliline commands. So to avoid confusion, this commit deals with this issue by simply disallowing abbreviations for multiline commands altogether. A warning has been added to the section on abbreviations in the documentation to hopefully make this clear for users.
1 parent 8297145 commit 64b3a88

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

cmd2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ class Cmd(cmd.Cmd):
600600
excludeFromHistory = '''run r list l history hi ed edit li eof'''.split()
601601
# make sure your terminators are not in legalChars!
602602
legalChars = u'!#$%.:?@_-' + pyparsing.alphanums + pyparsing.alphas8bit
603-
multilineCommands = []
603+
multilineCommands = [] # NOTE: Multiline commands can never be abbreviated, even if abbrev is True
604604
noSpecialParse = 'set ed edit exit'.split()
605605
prefixParser = pyparsing.Empty()
606606
redirector = '>' # for sending output to file
@@ -1089,7 +1089,7 @@ def func_named(self, arg):
10891089
result = target
10901090
else:
10911091
if self.abbrev: # accept shortened versions of commands
1092-
funcs = [fname for fname in self.keywords if fname.startswith(arg)]
1092+
funcs = [func for func in self.keywords if func.startswith(arg) and func not in self.multilineCommands]
10931093
if len(funcs) == 1:
10941094
result = 'do_' + funcs[0]
10951095
return result

docs/freefeatures.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,11 @@ no other commands defined beginning with *divid*,
243243

244244
This behavior can be turned off with ``app.abbrev`` (see :ref:`parameters`)
245245

246+
.. warning::
247+
248+
Due to the way the parsing logic works for multiline commands, abbreviations
249+
will not be accepted for multiline commands.
250+
246251
Misc. pre-defined commands
247252
==========================
248253

0 commit comments

Comments
 (0)