diff options
Diffstat (limited to 'cmd2/pyscript_bridge.py')
-rw-r--r-- | cmd2/pyscript_bridge.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/cmd2/pyscript_bridge.py b/cmd2/pyscript_bridge.py index c8db0960..b66fd701 100644 --- a/cmd2/pyscript_bridge.py +++ b/cmd2/pyscript_bridge.py @@ -250,7 +250,10 @@ class PyscriptBridge(object): self.cmd_echo = False def __getattr__(self, item: str): - """If attribute is a command, return a callable. Otherwise return the attribute.""" + """ + Provide a way to call application commands via the PyscriptBridge + ex: app.help() + """ func = self._cmd2_app.cmd_func(item) if func: @@ -264,7 +267,8 @@ class PyscriptBridge(object): return wrap_func else: - return getattr(self._cmd2_app, item) + # item does not refer to a command + raise AttributeError("'{}' object has no attribute '{}'".format(self._cmd2_app.pyscript_name, item)) def __dir__(self): """Return a custom set of attribute names to match the available commands""" |