diff options
author | kotfu <kotfu@kotfu.net> | 2018-05-27 17:15:12 -0600 |
---|---|---|
committer | kotfu <kotfu@kotfu.net> | 2018-05-27 17:15:12 -0600 |
commit | 019f69c3159707e1fb077317a33ffe343426b36c (patch) | |
tree | 01582040d2207123365b7ae3c25248332bf7978b | |
parent | bf0d0747514a5e84263e97d2094b0f6bc8a44e46 (diff) | |
parent | 8f88f819fae7508066a81a8d961a7115f2ec4bed (diff) | |
download | cmd2-git-019f69c3159707e1fb077317a33ffe343426b36c.tar.gz |
Merge branch 'master' into plugin_functions
-rw-r--r-- | cmd2/cmd2.py | 9 | ||||
-rwxr-xr-x | examples/python_scripting.py | 1 | ||||
-rw-r--r-- | examples/scripts/conditional.py | 6 | ||||
-rwxr-xr-x | main.py | 1 |
4 files changed, 5 insertions, 12 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index e0bd1493..d1d9747c 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -2597,15 +2597,6 @@ Usage: Usage: unalias [-a] name [name ...] except IOError as e: self.perror(e) - # noinspection PyUnusedLocal - def onecmd_plus_hooks(cmd_plus_args): - """Run a cmd2.Cmd command from a Python script or the interactive Python console. - - :param cmd_plus_args: str - command line including command and arguments to run - :return: bool - True if cmdloop() should exit once leaving the interactive Python console - """ - return self.onecmd_plus_hooks(cmd_plus_args + '\n') - bridge = PyscriptBridge(self) self.pystate['run'] = run self.pystate[self.pyscript_name] = bridge diff --git a/examples/python_scripting.py b/examples/python_scripting.py index 7e2cf345..fd2d7e8f 100755 --- a/examples/python_scripting.py +++ b/examples/python_scripting.py @@ -28,6 +28,7 @@ class CmdLineApp(cmd2.Cmd): super().__init__(use_ipython=True) self._set_prompt() self.intro = 'Happy 𝛑 Day. Note the full Unicode support: 😇 (Python 3 only) 💩' + self.locals_in_py = True def _set_prompt(self): """Set prompt so it displays the current working directory.""" diff --git a/examples/scripts/conditional.py b/examples/scripts/conditional.py index 1eeeadba..87cd10ac 100644 --- a/examples/scripts/conditional.py +++ b/examples/scripts/conditional.py @@ -24,16 +24,16 @@ else: original_dir = os.getcwd() # Try to change to the specified directory -cmd('cd {}'.format(directory)) +app('cd {}'.format(directory)) # Conditionally do something based on the results of the last command if self._last_result: print('\nContents of directory {!r}:'.format(directory)) - cmd('dir -l') + app('dir -l') # Change back to where we were print('Changing back to original directory: {!r}'.format(original_dir)) - cmd('cd {}'.format(original_dir)) + app('cd {}'.format(original_dir)) else: # cd command failed, print a warning print('Failed to change directory to {!r}'.format(directory)) @@ -8,4 +8,5 @@ if __name__ == '__main__': # Set "use_ipython" to True to include the ipy command if IPython is installed, which supports advanced interactive # debugging of your application via introspection on self. app = cmd2.Cmd(use_ipython=True) + app.locals_in_py = True app.cmdloop() |