summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorkotfu <kotfu@kotfu.net>2019-11-23 17:10:19 -0700
committerkotfu <kotfu@kotfu.net>2019-11-23 17:10:19 -0700
commitf58772040109e62b64c4781d0e8411fdc2f56ffb (patch)
treedf73925b01be1c72290be980831fecb8d082a165 /docs
parent3470018d919f6295ada022ce5078e015d6bbd287 (diff)
parentaeb517d7249b6f17cbb0d09a1a22f2d689be1d57 (diff)
downloadcmd2-git-f58772040109e62b64c4781d0e8411fdc2f56ffb.tar.gz
Merge branch 'master' into generating_output_docs
Diffstat (limited to 'docs')
-rw-r--r--docs/features/scripting.rst28
1 files changed, 26 insertions, 2 deletions
diff --git a/docs/features/scripting.rst b/docs/features/scripting.rst
index b41855ca..62af2e6d 100644
--- a/docs/features/scripting.rst
+++ b/docs/features/scripting.rst
@@ -59,7 +59,31 @@ session.
Python Scripts
--------------
+.. _arg_printer:
+ https://github.com/python-cmd2/cmd2/blob/master/examples/scripts/arg_printer.py
+
If you require logic flow, loops, branching, or other advanced features, you
can write a python script which executes in the context of your ``cmd2`` app.
-This script is run using the ``run_pyscript`` command. See
-:ref:`features/embedded_python_shells:Embedded Python Shells`.
+This script is run using the ``run_pyscript`` command. A simple example of
+using ``run_pyscript`` is shown below along with the arg_printer_ script::
+
+ (Cmd) run_pyscript examples/scripts/arg_printer.py foo bar 'baz 23'
+ Running Python script 'arg_printer.py' which was called with 3 arguments
+ arg 1: 'foo'
+ arg 2: 'bar'
+ arg 3: 'baz 23'
+
+``run_pyscript`` supports tab-completion of file system paths, and as shown
+above it has the ability to pass command-line arguments to the scripts invoked.
+
+Python scripts executed with ``run_pyscript`` can run ``cmd2`` application
+commands by using the syntax::
+
+ app(‘command args’)
+
+where:
+
+* ``app`` is a configurable name which can be changed by setting the
+ ``py_bridge_name`` attribute of your ``cmd2.Cmd`` class instance
+* ``command`` and ``args`` are entered exactly like they would be entered on
+ the command line of your ``cmd2`` application