Skip to content

Commit 2fb8078

Browse files
committed
Fixed bug where preparse() wasn't called before parsing
Also: - Deleted postparse() since it was redundant with postparsing_precmd()
1 parent 8f88f81 commit 2fb8078

File tree

2 files changed

+1
-12
lines changed

2 files changed

+1
-12
lines changed

cmd2/cmd2.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,15 +1619,6 @@ def preparse(self, raw: str) -> str:
16191619
"""
16201620
return raw
16211621

1622-
# noinspection PyMethodMayBeStatic
1623-
def postparse(self, statement: Statement) -> Statement:
1624-
"""Hook that runs immediately after parsing the user input.
1625-
1626-
:param statement: Statement object populated by parsing
1627-
:return: Statement - potentially modified Statement object
1628-
"""
1629-
return statement
1630-
16311622
# noinspection PyMethodMayBeStatic
16321623
def postparsing_precmd(self, statement: Statement) -> Tuple[bool, Statement]:
16331624
"""This runs after parsing the command-line, but before anything else; even before adding cmd to history.
@@ -1688,7 +1679,7 @@ def onecmd_plus_hooks(self, line):
16881679
import datetime
16891680
stop = False
16901681
try:
1691-
statement = self._complete_statement(line)
1682+
statement = self._complete_statement(self.preparse(line))
16921683
(stop, statement) = self.postparsing_precmd(statement)
16931684
if stop:
16941685
return self.postparsing_postcmd(stop)

docs/hooks.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ the various hook methods, presented in chronological order starting with the one
5050

5151
.. automethod:: cmd2.cmd2.Cmd.preparse
5252

53-
.. automethod:: cmd2.cmd2.Cmd.postparse
54-
5553
.. automethod:: cmd2.cmd2.Cmd.postparsing_precmd
5654

5755
.. automethod:: cmd2.cmd2.Cmd.precmd

0 commit comments

Comments
 (0)