summaryrefslogtreecommitdiff
path: root/examples/scripts/conditional.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2018-06-23 19:43:42 -0400
committerTodd Leonhardt <todd.leonhardt@gmail.com>2018-06-23 19:43:42 -0400
commitc8381601e4e3b31969ea6108617356572a7d1ca3 (patch)
tree023e67165ce45eba33739f248c1ee53b7c975d8f /examples/scripts/conditional.py
parentc7feaa60e46563cd60c217d27f888a05c9c3439d (diff)
downloadcmd2-git-c8381601e4e3b31969ea6108617356572a7d1ca3.tar.gz
Deprecated CmdResult helper class and promoted CommandResult
These classes are subtly different, particularly in terms of their truthiness. CmdResult - attributes: out, err, war - truthy: if err is falsy CommandResult - attributes: stdout, stderr, data - truthy: if err is falsy AND data is not None So CmdResult was oriented to provide essentially info, error, and warning messages to the user (typically as stirngs), whereas CommandResult is geared towards providing info and error messages to the user as strings in addition to data to the user in a command-specific format which is arbitrary other than it should never be None if the command succeeds.
Diffstat (limited to 'examples/scripts/conditional.py')
-rw-r--r--examples/scripts/conditional.py1
1 files changed, 1 insertions, 0 deletions
diff --git a/examples/scripts/conditional.py b/examples/scripts/conditional.py
index 87cd10ac..d7ee5ea2 100644
--- a/examples/scripts/conditional.py
+++ b/examples/scripts/conditional.py
@@ -30,6 +30,7 @@ app('cd {}'.format(directory))
if self._last_result:
print('\nContents of directory {!r}:'.format(directory))
app('dir -l')
+ print('{}\n'.format(self._last_result.data))
# Change back to where we were
print('Changing back to original directory: {!r}'.format(original_dir))