From 2bac6bcda3b7c5b2ba7093955acf232dd89f9f0f Mon Sep 17 00:00:00 2001 From: Kevin Van Brunt Date: Sat, 11 Apr 2020 13:04:52 -0400 Subject: Made some optional arguments with defaults keyword-only. Added unit test for echo argument to pyscript app() command. Removed _relative_load from hidden commands since that command was renamed. --- cmd2/py_bridge.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'cmd2/py_bridge.py') diff --git a/cmd2/py_bridge.py b/cmd2/py_bridge.py index 6624d7ad..0dc04ca6 100644 --- a/cmd2/py_bridge.py +++ b/cmd2/py_bridge.py @@ -74,25 +74,26 @@ class PyBridge: attributes.insert(0, 'cmd_echo') return attributes - def __call__(self, command: str, echo: Optional[bool] = None) -> CommandResult: + def __call__(self, command: str, *, echo: Optional[bool] = None) -> CommandResult: """ Provide functionality to call application commands by calling PyBridge ex: app('help') :param command: command line being run - :param echo: if True, output will be echoed to stdout/stderr while the command runs - this temporarily overrides the value of self.cmd_echo + :param echo: If provided, this temporarily overrides the value of self.cmd_echo while the + command runs. If True, output will be echoed to stdout/stderr. (Defaults to None) + """ if echo is None: echo = self.cmd_echo # This will be used to capture _cmd2_app.stdout and sys.stdout - copy_cmd_stdout = StdSim(self._cmd2_app.stdout, echo) + copy_cmd_stdout = StdSim(self._cmd2_app.stdout, echo=echo) # Pause the storing of stdout until onecmd_plus_hooks enables it copy_cmd_stdout.pause_storage = True # This will be used to capture sys.stderr - copy_stderr = StdSim(sys.stderr, echo) + copy_stderr = StdSim(sys.stderr, echo=echo) self._cmd2_app.last_result = None -- cgit v1.2.1