diff options
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rwxr-xr-x | cmd2/cmd2.py | 8 | ||||
-rw-r--r-- | tests/conftest.py | 4 | ||||
-rw-r--r-- | tests/transcripts/regex_set.txt | 2 |
4 files changed, 11 insertions, 5 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index bb577994..e84825de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * See the [tab_autocompletion.py](https://github.com/python-cmd2/cmd2/blob/master/examples/tab_autocompletion.py) example for a demonstration of how to use this feature * ``cmd2`` no longer depends on the ``six`` module * ``cmd2`` is now a multi-file Python package instead of a single-file module + * New pyscript approach that provides a pythonic interface to commands in the cmd2 application. * Deletions (potentially breaking changes) * Deleted all ``optparse`` code which had previously been deprecated in release 0.8.0 * The ``options`` decorator no longer exists @@ -12,6 +13,7 @@ * Alternatively, see the [argparse_example.py](https://github.com/python-cmd2/cmd2/blob/master/examples/argparse_example.py) * Deleted ``cmd_with_subs_completer``, ``get_subcommands``, and ``get_subcommand_completer`` * Replaced by default AutoCompleter implementation for all commands using argparse + * Deleted support for old method of calling application commands with ``cmd()`` and ``self`` * Python 2 no longer supported * ``cmd2`` now supports Python 3.4+ diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index 3a07f8ce..eb80351b 100755 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -699,7 +699,7 @@ class Cmd(cmd.Cmd): if _which(editor): break feedback_to_output = False # Do not include nonessentials in >, | output by default (things like timing) - locals_in_py = True + locals_in_py = False quiet = False # Do not suppress nonessential output timing = False # Prints elapsed time for each command @@ -2907,7 +2907,11 @@ Usage: Usage: unalias [-a] name [name ...] self.pystate['run'] = run self.pystate[self.pyscript_name] = bridge - localvars = (self.locals_in_py and self.pystate) or {} + if self.locals_in_py: + self.pystate['self'] = self + self.pystate['cmd'] = onecmd_plus_hooks + + localvars = self.pystate interp = InteractiveConsole(locals=localvars) interp.runcode('import sys, os;sys.path.insert(0, os.getcwd())') diff --git a/tests/conftest.py b/tests/conftest.py index ed76cba9..90d45bd9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -89,7 +89,7 @@ debug: False echo: False editor: vim feedback_to_output: False -locals_in_py: True +locals_in_py: False prompt: (Cmd) quiet: False timing: False @@ -106,7 +106,7 @@ debug: False # Show full error stack on error echo: False # Echo command issued into output editor: vim # Program used by ``edit`` feedback_to_output: False # Include nonessentials in `|`, `>` results -locals_in_py: True # Allow access to your application in py via self +locals_in_py: False # Allow access to your application in py via self prompt: (Cmd) # The prompt issued to solicit input quiet: False # Don't print nonessential feedback timing: False # Report execution times diff --git a/tests/transcripts/regex_set.txt b/tests/transcripts/regex_set.txt index bf88c294..b818c464 100644 --- a/tests/transcripts/regex_set.txt +++ b/tests/transcripts/regex_set.txt @@ -10,7 +10,7 @@ debug: False echo: False editor: /.*/ feedback_to_output: False -locals_in_py: True +locals_in_py: False maxrepeats: 3 prompt: (Cmd)/ / quiet: False |