diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-07-11 09:32:58 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-11 09:32:58 -0400 |
commit | 3869d718b36b05e38cfb959357c209d567fdfb8e (patch) | |
tree | cf4bdfe614f740d0b1ec33ff9eba0fc5a8c21e4f /cmd2 | |
parent | 951cc1c6d877dfac1d0afcca3ea84776a9960aa9 (diff) | |
parent | e10afbeb6efe7dd806b04bd53eca615bca5d5ffc (diff) | |
download | cmd2-git-3869d718b36b05e38cfb959357c209d567fdfb8e.tar.gz |
Merge branch 'master' into plugin_functions
Diffstat (limited to 'cmd2')
-rw-r--r-- | cmd2/cmd2.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index 356600c7..2cebe3f7 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -1961,14 +1961,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) |