diff options
author | Todd Leonhardt <tleonhardt@gmail.com> | 2017-03-14 16:53:22 -0400 |
---|---|---|
committer | Todd Leonhardt <tleonhardt@gmail.com> | 2017-03-14 16:53:22 -0400 |
commit | 28eba1722b12f1a270fffd9a8596044c5be6e7cd (patch) | |
tree | e85991423f473cbff3f31ca0814602c20ff49b51 /examples/script_conditional.py | |
parent | 7786709db04be8385226d6a56046a74983e8c983 (diff) | |
download | cmd2-git-28eba1722b12f1a270fffd9a8596044c5be6e7cd.tar.gz |
Improved the CmdResult namedtuple subclass
The last two arguments (err and war) are now optional.
Only the 1st argument (out) is required.
err and war default to empty strings.
Diffstat (limited to 'examples/script_conditional.py')
-rw-r--r-- | examples/script_conditional.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/examples/script_conditional.py b/examples/script_conditional.py index 3964ab6d..f0ded920 100644 --- a/examples/script_conditional.py +++ b/examples/script_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 py run('script_conditional.py') - + Note: The "cmd" function is defined within the cmd2 embedded Python environment and in there "self" is your cmd2 application instance. """ @@ -17,8 +17,14 @@ cmd('cd foobar') if self._last_result: print('Contents of foobar directory:') cmd('dir') + + # Change back to where we were + cmd('cd ..') else: # Change to parent directory cmd('cd ..') print('Contents of parent directory:') cmd('dir') + + # Change back to where we were + cmd('cd examples') |