summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2019-06-15 10:53:06 -0400
committerGitHub <noreply@github.com>2019-06-15 10:53:06 -0400
commitc12ba0ff11b3a8fd083c641cb9149aff6494bbf9 (patch)
treea858864c091088e633de6ba6c8db55fd618a71e7 /examples
parentb3759991adca62779ef7aefbff9dc7004463e129 (diff)
parent6a122ae91b6a3fabc3709b1d488843715258e58c (diff)
downloadcmd2-git-c12ba0ff11b3a8fd083c641cb9149aff6494bbf9.tar.gz
Merge pull request #701 from python-cmd2/rename
Rename load, _relative_load, and pyscript
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/alias_startup.py2
-rwxr-xr-xexamples/hooks.py4
-rwxr-xr-xexamples/persistent_history.py4
-rwxr-xr-xexamples/python_scripting.py12
-rw-r--r--examples/scripts/conditional.py2
-rw-r--r--examples/scripts/nested.txt6
-rw-r--r--examples/scripts/save_help_text.py2
7 files changed, 16 insertions, 16 deletions
diff --git a/examples/alias_startup.py b/examples/alias_startup.py
index b765e34c..052d1367 100755
--- a/examples/alias_startup.py
+++ b/examples/alias_startup.py
@@ -2,7 +2,7 @@
# coding=utf-8
"""A simple example demonstrating the following:
1) How to add custom command aliases using the alias command
- 2) How to load an initialization script at startup
+ 2) How to run an initialization script at startup
"""
import os
import cmd2
diff --git a/examples/hooks.py b/examples/hooks.py
index c533c696..42224403 100755
--- a/examples/hooks.py
+++ b/examples/hooks.py
@@ -38,10 +38,10 @@ class CmdLineApp(cmd2.Cmd):
# Setting this true makes it run a shell command if a cmd2/cmd command doesn't exist
# default_to_shell = True
def __init__(self, *args, **kwargs):
- # sneakily remove the cmd2.Cmd command called load
+ # sneakily remove the cmd2.Cmd command called run_script
# this lets a user enter a command like "l5" and allows it to
# be unambiguous
- delattr(cmd2.Cmd, "do_load")
+ delattr(cmd2.Cmd, "do_run_script")
super().__init__(*args, **kwargs)
diff --git a/examples/persistent_history.py b/examples/persistent_history.py
index e88fd5d9..bc62cb14 100755
--- a/examples/persistent_history.py
+++ b/examples/persistent_history.py
@@ -11,9 +11,9 @@ import cmd2
class Cmd2PersistentHistory(cmd2.Cmd):
"""Basic example of how to enable persistent readline history within your cmd2 app."""
def __init__(self, hist_file):
- """Configure the app to load persistent readline history from a file.
+ """Configure the app to load persistent history from a file (both readline and cmd2 history command affected).
- :param hist_file: file to load readline history from at start and write it to at end
+ :param hist_file: file to load history from at start and write it to at end
"""
super().__init__(persistent_history_file=hist_file, persistent_history_length=500, allow_cli_args=False)
self.prompt = 'ph> '
diff --git a/examples/python_scripting.py b/examples/python_scripting.py
index da7d0f6a..3e8f64ef 100755
--- a/examples/python_scripting.py
+++ b/examples/python_scripting.py
@@ -2,15 +2,15 @@
# 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 "load" command and uses basic ASCII
-text scripts 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 end users can quickly
-learn to create scripts.
+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 pyscript
-command and the "pyscript <script> [arguments]" syntax comes into play.
+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.
"""
diff --git a/examples/scripts/conditional.py b/examples/scripts/conditional.py
index 8a4f14de..724bb3ee 100644
--- a/examples/scripts/conditional.py
+++ b/examples/scripts/conditional.py
@@ -5,7 +5,7 @@ This is a Python script intended to be used with the "python_scripting.py" cmd2
To run it you should do the following:
./python_scripting.py
- pyscript scripts/conditional.py directory_path
+ run_pyscript scripts/conditional.py directory_path
Note: The "app" function is defined within the cmd2 embedded Python environment and in there "self" is your cmd2
application instance. Note: self only exists in this environment if locals_in_py is True.
diff --git a/examples/scripts/nested.txt b/examples/scripts/nested.txt
index 9ec26160..1b7e2035 100644
--- a/examples/scripts/nested.txt
+++ b/examples/scripts/nested.txt
@@ -1,3 +1,3 @@
-!echo "Doing a relative load"
-_relative_load script.txt
-
+!echo "Doing a relative run script"
+_relative_run_script script.txt
+
diff --git a/examples/scripts/save_help_text.py b/examples/scripts/save_help_text.py
index 73434a31..a68b0ad9 100644
--- a/examples/scripts/save_help_text.py
+++ b/examples/scripts/save_help_text.py
@@ -2,7 +2,7 @@
# flake8: noqa F821
"""
A cmd2 script that saves the help text for every command, sub-command, and topic to a file.
-This is meant to be run within a cmd2 session using pyscript.
+This is meant to be run within a cmd2 session using run_pyscript.
"""
import argparse