Skip to content

Commit 8b7f234

Browse files
committed
Updated documentation
1 parent beb2b37 commit 8b7f234

File tree

7 files changed

+21
-32
lines changed

7 files changed

+21
-32
lines changed

CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ examples/tab_au*.py @anselor
3535
examples/tab_co*.py @kmvanbrunt
3636

3737
# Unit Tests
38-
tests/pyscript/* @anselor
38+
tests/pyscript/* @anselor @kmvanbrunt
3939
tests/transcripts/* @kotfu
4040
tests/__init__.py @kotfu
4141
tests/conftest.py @kotfu @tleonhardt

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ Click on image below to watch a short video demonstrating the capabilities of cm
2020
Main Features
2121
-------------
2222
- Searchable command history (`history` command and `<Ctrl>+r`) - optionally persistent
23-
- Text file scripting of your application with `load` (`@`) and `_relative_load` (`@@`)
24-
- Python scripting of your application with ``pyscript``
23+
- Text file scripting of your application with `run_script` (`@`) and `_relative_run_script` (`@@`)
24+
- Python scripting of your application with ``run_pyscript``
2525
- Run shell commands with ``!``
2626
- Pipe command output to shell commands with `|`
2727
- Redirect command output to file with `>`, `>>`
@@ -111,7 +111,7 @@ Instructions for implementing each feature follow.
111111
- See [script.txt](https://github.com/python-cmd2/cmd2/blob/master/examples/scripts/script.txt) for a trivial example script that can be
112112
used in any `cmd2` application with the `load` command (or `@` shortcut)
113113

114-
- Powerful and flexible built-in Python scripting of your application using the `pyscript` command
114+
- Powerful and flexible built-in Python scripting of your application using the `run_pyscript` command
115115
- Run arbitrary Python scripts within your `cmd2` application with the ability to also call custom `cmd2` commands
116116
- No separate API for your end users to learn
117117
- Syntax for calling `cmd2` commands in a `pyscript` is essentially identical to what they would enter on the command line

cmd2/pyscript_bridge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# coding=utf-8
22
"""
3-
Bridges calls made inside of pyscript with the Cmd2 host app while maintaining a reasonable
3+
Bridges calls made inside of a pyscript with the Cmd2 host app while maintaining a reasonable
44
degree of isolation between the two
55
"""
66

docs/freefeatures.rst

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,15 @@ Script files
1313
============
1414

1515
Text files can serve as scripts for your ``cmd2``-based
16-
application, with the ``load``, ``_relative_load``, and ``edit`` commands.
16+
application, with the ``run_script``, ``_relative_run_script``, and ``edit`` commands.
1717

1818
Both ASCII and UTF-8 encoded unicode text files are supported.
1919

2020
Simply include one command per line, typed exactly as you would inside a ``cmd2`` application.
2121

22-
The ``load`` command loads commands from a script file into a queue and then the normal cmd2 REPL
23-
resumes control and executes the commands in the queue in FIFO order. A side effect of this
24-
is that if you redirect/pipe the output of a load command, it will redirect the output of the ``load``
25-
command itself, but will NOT redirect the output of the command loaded from the script file. Of course,
26-
you can add redirection to the commands being run in the script file, e.g.::
22+
.. automethod:: cmd2.cmd2.Cmd.do_run_script
2723

28-
# This is your script file
29-
command arg1 arg2 > file.txt
30-
31-
.. automethod:: cmd2.cmd2.Cmd.do_load
32-
33-
.. automethod:: cmd2.cmd2.Cmd.do__relative_load
24+
.. automethod:: cmd2.cmd2.Cmd.do__relative_run_script
3425

3526
.. automethod:: cmd2.cmd2.Cmd.do_edit
3627

@@ -51,7 +42,7 @@ Comments can be useful in :ref:`scripts`, but would be pointless within an inter
5142

5243
Startup Initialization Script
5344
=============================
54-
You can load and execute commands from a startup initialization script by passing a file path to the ``startup_script``
45+
You can execute commands from a startup initialization script by passing a file path to the ``startup_script``
5546
argument to the ``cmd2.Cmd.__init__()`` method like so::
5647

5748
class StartupApp(cmd2.Cmd):
@@ -188,16 +179,16 @@ conditional control flow logic. See the **python_scripting.py** ``cmd2`` applic
188179
the **script_conditional.py** script in the ``examples`` source code directory for an
189180
example of how to achieve this in your own applications.
190181

191-
Using ``py`` to run scripts directly is considered deprecated. The newer ``pyscript`` command
182+
Using ``py`` to run scripts directly is considered deprecated. The newer ``run_pyscript`` command
192183
is superior for doing this in two primary ways:
193184

194185
- it supports tab-completion of file system paths
195186
- it has the ability to pass command-line arguments to the scripts invoked
196187

197-
There are no disadvantages to using ``pyscript`` as opposed to ``py run()``. A simple example
198-
of using ``pyscript`` is shown below along with the arg_printer_ script::
188+
There are no disadvantages to using ``run_pyscript`` as opposed to ``py run()``. A simple example
189+
of using ``run_pyscript`` is shown below along with the arg_printer_ script::
199190

200-
(Cmd) pyscript examples/scripts/arg_printer.py foo bar baz
191+
(Cmd) run_pyscript examples/scripts/arg_printer.py foo bar baz
201192
Running Python script 'arg_printer.py' which was called with 3 arguments
202193
arg 1: 'foo'
203194
arg 2: 'bar'
@@ -390,7 +381,7 @@ would::
390381

391382
If you want to save the commands to a text file, but not edit and re-run them,
392383
use the ``-o`` or ``--output-file`` option. This is a great way to create
393-
:ref:`scripts`, which can be loaded and executed using the ``load`` command. To
384+
:ref:`scripts`, which can be executed using the ``run_script`` command. To
394385
save the first 5 commands entered in this session to a text file::
395386

396387
(Cmd) history :5 -o history.txt
@@ -512,8 +503,8 @@ Tab-Completion
512503
``cmd2`` adds tab-completion of file system paths for all built-in commands where it makes sense, including:
513504

514505
- ``edit``
515-
- ``load``
516-
- ``pyscript``
506+
- ``run_pyscript``
507+
- ``run_script``
517508
- ``shell``
518509

519510
``cmd2`` also adds tab-completion of shell commands to the ``shell`` command.

docs/integrating.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,7 @@ the main loop for the program by using code like the following::
128128
app.postloop()
129129

130130
The **runcmds_plus_hooks()** method is a convenience method to run multiple
131-
commands via **onecmd_plus_hooks()**. It properly deals with ``load`` commands
132-
which under the hood put commands in a FIFO queue as it reads them in from a
133-
script file.
131+
commands via **onecmd_plus_hooks()**.
134132

135133
The **onecmd_plus_hooks()** method will do the following to execute a single
136134
``cmd2`` command in a normal fashion:

docs/settingchanges.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ following shortcuts are defined:
2323
shell: run as OS-level command
2424

2525
``@``
26-
load script file
26+
run script file
2727

2828
``@@``
29-
load script file; filename is relative to current script location
29+
run script file; filename is relative to current script location
3030

3131
To define more shortcuts, update the dict ``App.shortcuts`` with the
3232
{'shortcut': 'command_name'} (omit ``do_``)::

docs/transcript.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ This is by far the easiest way to generate a transcript.
3434

3535
Automatically from a script file
3636
--------------------------------
37-
A transcript can also be automatically generated from a script file using ``load -t``::
37+
A transcript can also be automatically generated from a script file using ``run_script -t``::
3838

39-
(Cmd) load scripts/script.txt -t transcript.txt
39+
(Cmd) run_script scripts/script.txt -t transcript.txt
4040
2 commands and their outputs saved to transcript file 'transcript.txt'
4141
(Cmd)
4242

0 commit comments

Comments
 (0)