@@ -21,9 +21,10 @@ Creating Command Scripts
2121Command scripts can be created in several ways:
2222
2323- creating a text file using any method of your choice
24- - using the built-in ``edit `` command to create or edit an existing text file
25- - saving previously entered commands to a script file using ``history -s ``. See
26- :ref: `features/history:History ` for more details.
24+ - using the built-in :ref: `features/builtin_commands:edit ` command to
25+ create or edit an existing text file
26+ - saving previously entered commands to a script file using
27+ :ref: `history -s <features/history:For Users >`
2728
2829If you create create a text file from scratch, just include one command per
2930line, exactly as you would type it inside a ``cmd2 `` application.
@@ -32,11 +33,15 @@ line, exactly as you would type it inside a ``cmd2`` application.
3233Running Command Scripts
3334~~~~~~~~~~~~~~~~~~~~~~~
3435
35- Command script files can be executed using the built-in ``run_script `` command
36- or ``@ `` shortcut. Both ASCII and UTF-8 encoded unicode text files are
37- supported. The ``run_script `` command supports tab completion of file system
38- paths. There is a variant ``_relative_run_script `` command or ``@@ ``
39- shortcut for use within a script which uses paths relative to the first script.
36+ Command script files can be executed using the built-in
37+ :ref: `features/builtin_commands:run_script ` command or the ``@ `` shortcut (if
38+ your application is using the default shortcuts). Both ASCII and UTF-8 encoded
39+ unicode text files are supported. The
40+ :ref: `features/builtin_commands:run_script ` command supports tab completion of
41+ file system paths. There is a variant
42+ :ref: `features/builtin_commands:_relative_run_script ` command or ``@@ ``
43+ shortcut (if using the default shortcuts) for use within a script which uses
44+ paths relative to the first script.
4045
4146
4247Comments
@@ -64,26 +69,36 @@ Python Scripts
6469
6570If you require logic flow, loops, branching, or other advanced features, you
6671can write a python script which executes in the context of your ``cmd2 `` app.
67- This script is run using the `` run_pyscript `` command. A simple example of
68- using `` run_pyscript `` is shown below along with the arg_printer _ script::
72+ This script is run using the :ref: ` features/builtin_commands: run_pyscript `
73+ command. Here's a simple example that uses the arg_printer _ script::
6974
7075 (Cmd) run_pyscript examples/scripts/arg_printer.py foo bar 'baz 23'
7176 Running Python script 'arg_printer.py' which was called with 3 arguments
7277 arg 1: 'foo'
7378 arg 2: 'bar'
7479 arg 3: 'baz 23'
7580
76- ``run_pyscript `` supports tab completion of file system paths, and as shown
77- above it has the ability to pass command-line arguments to the scripts invoked.
81+ :ref: `features/builtin_commands:run_pyscript ` supports tab completion of file
82+ system paths, and as shown above it has the ability to pass command-line
83+ arguments to the scripts invoked.
7884
79- Python scripts executed with `` run_pyscript `` can run `` cmd2 `` application
80- commands by using the syntax::
85+ Python scripts executed with :ref: ` features/builtin_commands: run_pyscript ` can
86+ run `` cmd2 `` application commands by using the syntax::
8187
8288 app(‘command args’)
8389
8490where:
8591
8692* ``app `` is a configurable name which can be changed by setting the
87- ``py_bridge_name `` attribute of your ``cmd2.Cmd `` class instance
88- * ``command `` and ``args `` are entered exactly like they would be entered on
89- the command line of your ``cmd2 `` application
93+ :data: `cmd2.Cmd.py_bridge_name ` attribute
94+ * ``command `` and ``args `` are entered exactly like they would be entered by
95+ a user of your application.
96+
97+ .. _python_scripting :
98+ https://github.com/python-cmd2/cmd2/blob/master/examples/python_scripting.py
99+
100+ .. _conditional :
101+ https://github.com/python-cmd2/cmd2/blob/master/examples/scripts/conditional.py
102+
103+ See python_scripting _ example and associated conditional _ script for more
104+ information.
0 commit comments