diff options
author | kotfu <kotfu@kotfu.net> | 2020-02-28 21:29:50 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-28 21:29:50 -0700 |
commit | cc38f5d348e9fb566565938acb2352174efbd313 (patch) | |
tree | d9ec61d7cce8b508f672e88eef93b79cc7f7ebe0 /examples/python_scripting.py | |
parent | 94f3c4cd0291146c1e28aba90c0c32e76140d5e0 (diff) | |
parent | f2302042e2edad5fcabd17fa4f7f2bc08c1003fc (diff) | |
download | cmd2-git-cc38f5d348e9fb566565938acb2352174efbd313.tar.gz |
Merge pull request #904 from python-cmd2/scripting_docs
Update scripting docs. Closes #765.
Diffstat (limited to 'examples/python_scripting.py')
-rwxr-xr-x | examples/python_scripting.py | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/examples/python_scripting.py b/examples/python_scripting.py index 62dd3091..69cfb672 100755 --- a/examples/python_scripting.py +++ b/examples/python_scripting.py @@ -1,18 +1,24 @@ #!/usr/bin/env python # 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 "run_script" command, uses basic -ASCII/UTF-8 text scripts and 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 -that 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 -from the previous command. This is where the ability to run Python scripts inside a cmd2 application via the -run_pyscript command and the "run_pyscript <script> [arguments]" syntax comes into play. - -This application and the "scripts/conditional.py" script serve as an example for one way in which this can be done. +"""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 "run_script" command, uses basic ASCII/UTF-8 text scripts and 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 that 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 from the previous command. This is where the ability to run Python +scripts inside a cmd2 application via the run_pyscript command and the +"run_pyscript <script> [arguments]" syntax comes into play. + +This application and the "examples/scripts/conditional.py" script serve as an +example for one way in which this can be done. """ import argparse import os |