summaryrefslogtreecommitdiff
path: root/examples/arg_print.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/arg_print.py')
-rwxr-xr-xexamples/arg_print.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/examples/arg_print.py b/examples/arg_print.py
index 1e6babc1..4f0ca709 100755
--- a/examples/arg_print.py
+++ b/examples/arg_print.py
@@ -2,10 +2,11 @@
# coding=utf-8
"""A simple example demonstrating the following:
1) How arguments and options get parsed and passed to commands
- 2) How to change what syntax get parsed as a comment and stripped from the arguments
+ 2) How to change what syntax get parsed as a comment and stripped from
+ the arguments
-This is intended to serve as a live demonstration so that developers can experiment with and understand how command
-and argument parsing is intended to work.
+This is intended to serve as a live demonstration so that developers can
+experiment with and understand how command and argument parsing work.
It also serves as an example of how to create command aliases (shortcuts).
"""
@@ -25,9 +26,12 @@ class ArgumentAndOptionPrinter(cmd2.Cmd):
# NOTE: It is critical that the super class __init__ method be called AFTER updating certain parameters which
# are not settable at runtime. This includes the shortcuts, multiline_commands, etc.
- def do_aprint(self, arg):
+ def do_aprint(self, statement):
"""Print the argument string this basic command is called with."""
- self.poutput('aprint was called with argument: {!r}'.format(arg))
+ self.poutput('aprint was called with argument: {!r}'.format(statement))
+ self.poutput('statement.raw = {!r}'.format(statement.raw))
+ self.poutput('statement.argv = {!r}'.format(statement.argv))
+ self.poutput('statement.command = {!r}'.format(statement.command))
@cmd2.with_argument_list
def do_lprint(self, arglist):