summaryrefslogtreecommitdiff
path: root/cmd2
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2020-04-11 14:08:21 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2020-04-11 14:08:21 -0400
commitf223e96cfb0be13881ebf304d0720f0633b7fe46 (patch)
tree3d7e50b35cbcce179529c494e58d12b11fd87908 /cmd2
parentc4fbd8fa618b5c48cc38ac5c262d3c1ec53ce9af (diff)
downloadcmd2-git-f223e96cfb0be13881ebf304d0720f0633b7fe46.tar.gz
Simplified onecmd_plus_hooks by reducing number of calls to _run_cmdfinalization_hooks()
Diffstat (limited to 'cmd2')
-rw-r--r--cmd2/cmd2.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index de7e7f5a..d6cb0ee1 100644
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -1600,21 +1600,19 @@ class Cmd(cmd.Cmd):
import datetime
stop = False
+ statement = None
+
try:
+ # Convert the line into a Statement
statement = self._input_line_to_statement(line)
- except (EmptyStatement, Cmd2ShlexError) as ex:
- if isinstance(ex, Cmd2ShlexError):
- self.perror("Invalid syntax: {}".format(ex))
- return self._run_cmdfinalization_hooks(stop, None)
- # now that we have a statement, run it with all the hooks
- try:
# call the postparsing hooks
data = plugin.PostparsingData(False, statement)
for func in self._postparsing_hooks:
data = func(data)
if data.stop:
break
+
# unpack the data object
statement = data.statement
stop = data.stop
@@ -1690,6 +1688,8 @@ class Cmd(cmd.Cmd):
except (Cmd2ArgparseError, EmptyStatement):
# Don't do anything, but do allow command finalization hooks to run
pass
+ except Cmd2ShlexError as ex:
+ self.perror("Invalid syntax: {}".format(ex))
except Exception as ex:
self.pexcept(ex)
finally: