summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/argparse_example.py6
-rwxr-xr-xexamples/event_loops.py4
-rwxr-xr-xexamples/example.py2
-rwxr-xr-xexamples/pirate.py2
-rw-r--r--examples/script.py4
-rw-r--r--examples/script_conditional.py2
6 files changed, 13 insertions, 7 deletions
diff --git a/examples/argparse_example.py b/examples/argparse_example.py
index 8f833578..c6cc819b 100755
--- a/examples/argparse_example.py
+++ b/examples/argparse_example.py
@@ -3,7 +3,7 @@
"""A sample application for cmd2 showing how to use Argparse to process command line arguments for your application.
It doubles as an example of how you can still do transcript testing even if allow_cli_args is false.
-Thanks to cmd2's built-in transtript testing capability, it also serves as a test suite for argparse_example.py when
+Thanks to cmd2's built-in transcript testing capability, it also serves as a test suite for argparse_example.py when
used with the exampleSession.txt transcript.
Running `python argparse_example.py -t exampleSession.txt` will run all the commands in the transcript against
@@ -77,11 +77,11 @@ if __name__ == '__main__':
if args.ip:
ip_addr = args.ip
- transcript = None
+ transcripts = None
if args.test:
transcripts = [args.test]
- # Instantiate your cmd2 applicaiton
+ # Instantiate your cmd2 application
c = CmdLineApp(transcript_files=transcripts)
# And run your cmd2 application
diff --git a/examples/event_loops.py b/examples/event_loops.py
index e3e5880c..24efa830 100755
--- a/examples/event_loops.py
+++ b/examples/event_loops.py
@@ -10,6 +10,7 @@ import cmd2
class Cmd2EventBased(cmd2.Cmd):
+ """Basic example of how to run cmd2 without it controlling the main loop."""
def __init__(self):
cmd2.Cmd.__init__(self)
@@ -20,7 +21,8 @@ if __name__ == '__main__':
app = Cmd2EventBased()
app.preloop()
- # Do this within whatever event loop mechanism you wish to run a single command
+ # Do this within whatever event loop mechanism you wish to run a single command.
+ # In this case, no prompt is generated, so you need to provide one and read the user's input.
app.onecmd_plus_hooks("help history")
app.postloop()
diff --git a/examples/example.py b/examples/example.py
index f39be5de..cb4aba04 100755
--- a/examples/example.py
+++ b/examples/example.py
@@ -2,7 +2,7 @@
# coding=utf-8
"""A sample application for cmd2.
-Thanks to cmd2's built-in transtript testing capability, it also serves as a test suite for example.py when used with
+Thanks to cmd2's built-in transcript testing capability, it also serves as a test suite for example.py when used with
the exampleSession.txt transcript.
Running `python example.py -t exampleSession.txt` will run all the commands in the transcript against example.py,
diff --git a/examples/pirate.py b/examples/pirate.py
index 03745ed4..4fd7e6be 100755
--- a/examples/pirate.py
+++ b/examples/pirate.py
@@ -62,7 +62,7 @@ class Pirate(Cmd):
self.gold -= 1
def do_quit(self, arg):
- """Quit the applicaiton gracefully."""
+ """Quit the application gracefully."""
print("Quiterrr!")
return True
diff --git a/examples/script.py b/examples/script.py
index 7d0c998a..3f60c8fb 100644
--- a/examples/script.py
+++ b/examples/script.py
@@ -1,3 +1,7 @@
#!/usr/bin/env python
+# coding=utf-8
+"""
+Trivial example of a Python script which can be run inside a cmd2 application.
+"""
print("This is a python script running ...")
diff --git a/examples/script_conditional.py b/examples/script_conditional.py
index cbfb0494..3964ab6d 100644
--- a/examples/script_conditional.py
+++ b/examples/script_conditional.py
@@ -1,6 +1,6 @@
# coding=utf-8
"""
-This is a Python script intended to be used with the "python_scripting.py" cmd2 example applicaiton.
+This is a Python script intended to be used with the "python_scripting.py" cmd2 example application.
To run it you should do the following:
./python_scripting.py