Skip to content

Commit 8f88f81

Browse files
authored
Merge pull request #419 from python-cmd2/py_updates
Removed unused function
2 parents 6b6a36c + 906feb7 commit 8f88f81

File tree

4 files changed

+5
-12
lines changed

4 files changed

+5
-12
lines changed

cmd2/cmd2.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2569,15 +2569,6 @@ def run(filename):
25692569
except IOError as e:
25702570
self.perror(e)
25712571

2572-
# noinspection PyUnusedLocal
2573-
def onecmd_plus_hooks(cmd_plus_args):
2574-
"""Run a cmd2.Cmd command from a Python script or the interactive Python console.
2575-
2576-
:param cmd_plus_args: str - command line including command and arguments to run
2577-
:return: bool - True if cmdloop() should exit once leaving the interactive Python console
2578-
"""
2579-
return self.onecmd_plus_hooks(cmd_plus_args + '\n')
2580-
25812572
bridge = PyscriptBridge(self)
25822573
self.pystate['run'] = run
25832574
self.pystate[self.pyscript_name] = bridge

examples/python_scripting.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def __init__(self):
2828
super().__init__(use_ipython=True)
2929
self._set_prompt()
3030
self.intro = 'Happy 𝛑 Day. Note the full Unicode support: 😇 (Python 3 only) 💩'
31+
self.locals_in_py = True
3132

3233
def _set_prompt(self):
3334
"""Set prompt so it displays the current working directory."""

examples/scripts/conditional.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@
2424
original_dir = os.getcwd()
2525

2626
# Try to change to the specified directory
27-
cmd('cd {}'.format(directory))
27+
app('cd {}'.format(directory))
2828

2929
# Conditionally do something based on the results of the last command
3030
if self._last_result:
3131
print('\nContents of directory {!r}:'.format(directory))
32-
cmd('dir -l')
32+
app('dir -l')
3333

3434
# Change back to where we were
3535
print('Changing back to original directory: {!r}'.format(original_dir))
36-
cmd('cd {}'.format(original_dir))
36+
app('cd {}'.format(original_dir))
3737
else:
3838
# cd command failed, print a warning
3939
print('Failed to change directory to {!r}'.format(directory))

main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
# Set "use_ipython" to True to include the ipy command if IPython is installed, which supports advanced interactive
99
# debugging of your application via introspection on self.
1010
app = cmd2.Cmd(use_ipython=True)
11+
app.locals_in_py = True
1112
app.cmdloop()

0 commit comments

Comments
 (0)