diff options
-rwxr-xr-x | README.md | 6 | ||||
-rw-r--r-- | docs/integrating.rst | 5 | ||||
-rw-r--r-- | docs/unfreefeatures.rst | 4 | ||||
-rwxr-xr-x | examples/persistent_history.py | 4 | ||||
-rwxr-xr-x | examples/python_scripting.py | 8 | ||||
-rw-r--r-- | tests/test_completion.py | 2 | ||||
-rw-r--r-- | tests/test_transcript.py | 6 |
7 files changed, 18 insertions, 17 deletions
@@ -32,7 +32,7 @@ Main Features - Special-character command shortcuts (beyond cmd's `?` and `!`) - Command aliasing similar to bash `alias` command - Macros, which are similar to aliases, but they can contain argument placeholders -- Ability to load commands at startup from an initialization script +- Ability to run commands at startup from an initialization script - Settable environment parameters - Parsing commands with arguments using `argparse`, including support for sub-commands - Unicode character support @@ -109,12 +109,12 @@ Instructions for implementing each feature follow. - Simple scripting using ASCII text files with one command + arguments per line - See the [Script files](https://cmd2.readthedocs.io/en/latest/freefeatures.html#script-files) section of the `cmd2` docs for more info - See [script.txt](https://github.com/python-cmd2/cmd2/blob/master/examples/scripts/script.txt) for a trivial example script that can be - used in any `cmd2` application with the `load` command (or `@` shortcut) + used in any `cmd2` application with the `run_script` command (or `@` shortcut) - Powerful and flexible built-in Python scripting of your application using the `run_pyscript` command - Run arbitrary Python scripts within your `cmd2` application with the ability to also call custom `cmd2` commands - No separate API for your end users to learn - - Syntax for calling `cmd2` commands in a `pyscript` is essentially identical to what they would enter on the command line + - Syntax for calling `cmd2` commands in a `run_pyscript` is essentially identical to what they would enter on the command line - See the [Python](https://cmd2.readthedocs.io/en/latest/freefeatures.html#python) section of the `cmd2` docs for more info - Also see the [python_scripting.py](https://github.com/python-cmd2/cmd2/blob/master/examples/python_scripting.py) example in conjunction with the [conditional.py](https://github.com/python-cmd2/cmd2/blob/master/examples/scripts/conditional.py) script diff --git a/docs/integrating.rst b/docs/integrating.rst index aeb8ceca..352bb2f0 100644 --- a/docs/integrating.rst +++ b/docs/integrating.rst @@ -45,8 +45,9 @@ loop:: Documented commands (type help <topic>): ======================================== - alias help load orate pyscript say shell speak - edit history mumble py quit set shortcuts unalias + alias history mumble pyscript run_script shell + edit load orate quit say shortcuts + help macro py run_pyscript set speak (Cmd) diff --git a/docs/unfreefeatures.rst b/docs/unfreefeatures.rst index 81be76d8..ada3a2f6 100644 --- a/docs/unfreefeatures.rst +++ b/docs/unfreefeatures.rst @@ -359,10 +359,10 @@ the help categories with per-command Help Messages:: edit Edit a file in a text editor help List available commands with "help" or detailed help with "help cmd" history usage: history [-h] [-r | -e | -s | -o FILE | -t TRANSCRIPT] [arg] - load Runs commands in script file that is encoded as either ASCII or UTF-8 text py Invoke python command, shell, or script - pyscript Runs a python script file inside the console quit Exits this application + run_pyscript Runs a python script file inside the console + run_script Runs commands in script file that is encoded as either ASCII or UTF-8 text set usage: set [-h] [-a] [-l] [settable [settable ...]] shell Execute a command as if at the OS prompt shortcuts Lists shortcuts available diff --git a/examples/persistent_history.py b/examples/persistent_history.py index e88fd5d9..bc62cb14 100755 --- a/examples/persistent_history.py +++ b/examples/persistent_history.py @@ -11,9 +11,9 @@ import cmd2 class Cmd2PersistentHistory(cmd2.Cmd): """Basic example of how to enable persistent readline history within your cmd2 app.""" def __init__(self, hist_file): - """Configure the app to load persistent readline history from a file. + """Configure the app to load persistent history from a file (both readline and cmd2 history command affected). - :param hist_file: file to load readline history from at start and write it to at end + :param hist_file: file to load history from at start and write it to at end """ super().__init__(persistent_history_file=hist_file, persistent_history_length=500, allow_cli_args=False) self.prompt = 'ph> ' diff --git a/examples/python_scripting.py b/examples/python_scripting.py index 88bc2f98..5b241192 100755 --- a/examples/python_scripting.py +++ b/examples/python_scripting.py @@ -2,10 +2,10 @@ # coding=utf-8 """A sample application for how Python scripting can provide conditional control flow of a cmd2 application. -cmd2's built-in scripting capability which can be invoked via the "@" shortcut or "load" command and uses basic ASCII -text scripts is very easy to use. Moreover, the trivial syntax of the script files where there is one command per line -and the line is exactly what the user would type inside the application makes it so non-technical end users can quickly -learn to create scripts. +cmd2's built-in scripting capability which can be invoked via the "@" shortcut or "run_script" command and uses basic +ASCII text scripts is very easy to use. Moreover, the trivial syntax of the script files where there is one command per +line and the line is exactly what the user would type inside the application makes it so non-technical end users can +quickly learn to create scripts. However, there comes a time when technical end users want more capability and power. In particular it is common that users will want to create a script with conditional control flow - where the next command run will depend on the results diff --git a/tests/test_completion.py b/tests/test_completion.py index b70de7bc..91519b0a 100644 --- a/tests/test_completion.py +++ b/tests/test_completion.py @@ -537,7 +537,7 @@ def test_basic_completion_nomatch(cmd2_app): def test_delimiter_completion(cmd2_app): text = '/home/' - line = 'load {}'.format(text) + line = 'run_script {}'.format(text) endidx = len(line) begidx = endidx - len(text) diff --git a/tests/test_transcript.py b/tests/test_transcript.py index 5dd39e1b..909a6a5c 100644 --- a/tests/test_transcript.py +++ b/tests/test_transcript.py @@ -190,7 +190,7 @@ this is a \/multiline\/ command assert transcript == expected -def test_load_record_transcript(base_app, request): +def test_run_script_record_transcript(base_app, request): test_dir = os.path.dirname(request.module.__file__) filename = os.path.join(test_dir, 'scripts', 'help.txt') @@ -201,8 +201,8 @@ def test_load_record_transcript(base_app, request): fd, transcript_fname = tempfile.mkstemp(prefix='', suffix='.trn') os.close(fd) - # Run the load command with the -r option to generate a transcript - run_cmd(base_app, 'load {} -t {}'.format(filename, transcript_fname)) + # Execute the run_script command with the -t option to generate a transcript + run_cmd(base_app, 'run_script {} -t {}'.format(filename, transcript_fname)) assert base_app._script_dir == [] assert base_app._current_script_dir is None |