diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/freefeatures.rst | 31 | ||||
-rw-r--r-- | docs/integrating.rst | 4 | ||||
-rw-r--r-- | docs/settingchanges.rst | 4 | ||||
-rw-r--r-- | docs/transcript.rst | 4 |
4 files changed, 16 insertions, 27 deletions
diff --git a/docs/freefeatures.rst b/docs/freefeatures.rst index 12421601..a06bab90 100644 --- a/docs/freefeatures.rst +++ b/docs/freefeatures.rst @@ -13,24 +13,15 @@ Script files ============ Text files can serve as scripts for your ``cmd2``-based -application, with the ``load``, ``_relative_load``, and ``edit`` commands. +application, with the ``run_script``, ``_relative_run_script``, and ``edit`` commands. Both ASCII and UTF-8 encoded unicode text files are supported. Simply include one command per line, typed exactly as you would inside a ``cmd2`` application. -The ``load`` command loads commands from a script file into a queue and then the normal cmd2 REPL -resumes control and executes the commands in the queue in FIFO order. A side effect of this -is that if you redirect/pipe the output of a load command, it will redirect the output of the ``load`` -command itself, but will NOT redirect the output of the command loaded from the script file. Of course, -you can add redirection to the commands being run in the script file, e.g.:: +.. automethod:: cmd2.cmd2.Cmd.do_run_script - # This is your script file - command arg1 arg2 > file.txt - -.. automethod:: cmd2.cmd2.Cmd.do_load - -.. automethod:: cmd2.cmd2.Cmd.do__relative_load +.. automethod:: cmd2.cmd2.Cmd.do__relative_run_script .. automethod:: cmd2.cmd2.Cmd.do_edit @@ -51,7 +42,7 @@ Comments can be useful in :ref:`scripts`, but would be pointless within an inter Startup Initialization Script ============================= -You can load and execute commands from a startup initialization script by passing a file path to the ``startup_script`` +You can execute commands from a startup initialization script by passing a file path to the ``startup_script`` argument to the ``cmd2.Cmd.__init__()`` method like so:: class StartupApp(cmd2.Cmd): @@ -188,16 +179,16 @@ conditional control flow logic. See the **python_scripting.py** ``cmd2`` applic the **script_conditional.py** script in the ``examples`` source code directory for an example of how to achieve this in your own applications. -Using ``py`` to run scripts directly is considered deprecated. The newer ``pyscript`` command +Using ``py`` to run scripts directly is considered deprecated. The newer ``run_pyscript`` command is superior for doing this in two primary ways: - it supports tab-completion of file system paths - it has the ability to pass command-line arguments to the scripts invoked -There are no disadvantages to using ``pyscript`` as opposed to ``py run()``. A simple example -of using ``pyscript`` is shown below along with the arg_printer_ script:: +There are no disadvantages to using ``run_pyscript`` as opposed to ``py run()``. A simple example +of using ``run_pyscript`` is shown below along with the arg_printer_ script:: - (Cmd) pyscript examples/scripts/arg_printer.py foo bar baz + (Cmd) run_pyscript examples/scripts/arg_printer.py foo bar baz Running Python script 'arg_printer.py' which was called with 3 arguments arg 1: 'foo' arg 2: 'bar' @@ -390,7 +381,7 @@ would:: If you want to save the commands to a text file, but not edit and re-run them, use the ``-o`` or ``--output-file`` option. This is a great way to create -:ref:`scripts`, which can be loaded and executed using the ``load`` command. To +:ref:`scripts`, which can be executed using the ``run_script`` command. To save the first 5 commands entered in this session to a text file:: (Cmd) history :5 -o history.txt @@ -512,8 +503,8 @@ Tab-Completion ``cmd2`` adds tab-completion of file system paths for all built-in commands where it makes sense, including: - ``edit`` -- ``load`` -- ``pyscript`` +- ``run_pyscript`` +- ``run_script`` - ``shell`` ``cmd2`` also adds tab-completion of shell commands to the ``shell`` command. diff --git a/docs/integrating.rst b/docs/integrating.rst index a8377fdb..aeb8ceca 100644 --- a/docs/integrating.rst +++ b/docs/integrating.rst @@ -128,9 +128,7 @@ the main loop for the program by using code like the following:: app.postloop() The **runcmds_plus_hooks()** method is a convenience method to run multiple -commands via **onecmd_plus_hooks()**. It properly deals with ``load`` commands -which under the hood put commands in a FIFO queue as it reads them in from a -script file. +commands via **onecmd_plus_hooks()**. The **onecmd_plus_hooks()** method will do the following to execute a single ``cmd2`` command in a normal fashion: diff --git a/docs/settingchanges.rst b/docs/settingchanges.rst index b9ad4a22..aa6d9084 100644 --- a/docs/settingchanges.rst +++ b/docs/settingchanges.rst @@ -23,10 +23,10 @@ following shortcuts are defined: shell: run as OS-level command ``@`` - load script file + run script file ``@@`` - load script file; filename is relative to current script location + run script file; filename is relative to current script location To define more shortcuts, update the dict ``App.shortcuts`` with the {'shortcut': 'command_name'} (omit ``do_``):: diff --git a/docs/transcript.rst b/docs/transcript.rst index c7c31fd6..089ab704 100644 --- a/docs/transcript.rst +++ b/docs/transcript.rst @@ -34,9 +34,9 @@ This is by far the easiest way to generate a transcript. Automatically from a script file -------------------------------- -A transcript can also be automatically generated from a script file using ``load -t``:: +A transcript can also be automatically generated from a script file using ``run_script -t``:: - (Cmd) load scripts/script.txt -t transcript.txt + (Cmd) run_script scripts/script.txt -t transcript.txt 2 commands and their outputs saved to transcript file 'transcript.txt' (Cmd) |