summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2019-06-23 20:49:27 -0400
committerTodd Leonhardt <todd.leonhardt@gmail.com>2019-06-23 20:49:27 -0400
commit652122f3c9907a652a9c3a14581bb2aef90bc996 (patch)
tree9bcb0c07c2e2cee26553a1e11a1d9dbcb7225954 /examples
parent181cecb217dd73056b72874d225e34528d484de8 (diff)
downloadcmd2-git-652122f3c9907a652a9c3a14581bb2aef90bc996.tar.gz
Made last_result public and restored the initialization of it in __init__ and associated comment
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/python_scripting.py8
-rw-r--r--examples/scripts/conditional.py4
2 files changed, 6 insertions, 6 deletions
diff --git a/examples/python_scripting.py b/examples/python_scripting.py
index 3e8f64ef..c45648bc 100755
--- a/examples/python_scripting.py
+++ b/examples/python_scripting.py
@@ -58,7 +58,7 @@ class CmdLineApp(cmd2.Cmd):
if not arglist or len(arglist) != 1:
self.perror("cd requires exactly 1 argument:", traceback_war=False)
self.do_help('cd')
- self._last_result = cmd2.CommandResult('', 'Bad arguments')
+ self.last_result = cmd2.CommandResult('', 'Bad arguments')
return
# Convert relative paths to absolute paths
@@ -84,7 +84,7 @@ class CmdLineApp(cmd2.Cmd):
if err:
self.perror(err, traceback_war=False)
- self._last_result = cmd2.CommandResult(out, err, data)
+ self.last_result = cmd2.CommandResult(out, err, data)
# Enable tab completion for cd command
def complete_cd(self, text, line, begidx, endidx):
@@ -100,7 +100,7 @@ class CmdLineApp(cmd2.Cmd):
if unknown:
self.perror("dir does not take any positional arguments:", traceback_war=False)
self.do_help('dir')
- self._last_result = cmd2.CommandResult('', 'Bad arguments')
+ self.last_result = cmd2.CommandResult('', 'Bad arguments')
return
# Get the contents as a list
@@ -113,7 +113,7 @@ class CmdLineApp(cmd2.Cmd):
self.stdout.write(fmt.format(f))
self.stdout.write('\n')
- self._last_result = cmd2.CommandResult(data=contents)
+ self.last_result = cmd2.CommandResult(data=contents)
if __name__ == '__main__':
diff --git a/examples/scripts/conditional.py b/examples/scripts/conditional.py
index 724bb3ee..2e307cb4 100644
--- a/examples/scripts/conditional.py
+++ b/examples/scripts/conditional.py
@@ -27,10 +27,10 @@ original_dir = os.getcwd()
app('cd {}'.format(directory))
# Conditionally do something based on the results of the last command
-if self._last_result:
+if self.last_result:
print('\nContents of directory {!r}:'.format(directory))
app('dir -l')
- print('{}\n'.format(self._last_result.data))
+ print('{}\n'.format(self.last_result.data))
# Change back to where we were
print('Changing back to original directory: {!r}'.format(original_dir))