summaryrefslogtreecommitdiff
path: root/cmd2/cmd2.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2018-07-12 00:31:15 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2018-07-12 00:31:15 -0400
commit297eff0540c2115d817dbe4338830b23bdddd9a0 (patch)
tree846067a6c68cbf43fa47a56ff8e300b62f7b3836 /cmd2/cmd2.py
parent969dab29bbaed194edce881d60643f5e95a02366 (diff)
parente10afbeb6efe7dd806b04bd53eca615bca5d5ffc (diff)
downloadcmd2-git-297eff0540c2115d817dbe4338830b23bdddd9a0.tar.gz
Merge branch 'master' into history
Diffstat (limited to 'cmd2/cmd2.py')
-rw-r--r--cmd2/cmd2.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index bdb8452a..c6914b95 100644
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -1920,14 +1920,19 @@ class Cmd(cmd.Cmd):
result = target
return result
- def onecmd(self, statement: Statement) -> Optional[bool]:
+ def onecmd(self, statement: Union[Statement, str]) -> Optional[bool]:
""" This executes the actual do_* method for a command.
If the command provided doesn't exist, then it executes _default() instead.
- :param statement: Command - a parsed command from the input stream
+ :param statement: Command - intended to be a Statement instance parsed command from the input stream,
+ alternative acceptance of a str is present only for backward compatibility with cmd
:return: a flag indicating whether the interpretation of commands should stop
"""
+ # For backwards compatibility with cmd, allow a str to be passed in
+ if not isinstance(statement, Statement):
+ statement = self._complete_statement(statement)
+
funcname = self._func_named(statement.command)
if not funcname:
self.default(statement)