summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2019-05-24 13:50:38 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2019-05-24 13:50:38 -0400
commitba4de1da1a7cecaf65c264b31528b82183daacbb (patch)
treed905b6ad0deb0e59714337b3162d01e0506a870a
parentc3fe0573e2877c76adc6209453a92ef82ff6b6f2 (diff)
downloadcmd2-git-ba4de1da1a7cecaf65c264b31528b82183daacbb.tar.gz
Stopping transcript generation if a command returns True for its stop value
-rw-r--r--cmd2/cmd2.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index 32d0ae09..8911a188 100644
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -3491,13 +3491,16 @@ class Cmd(cmd.Cmd):
membuf = io.StringIO()
self.stdout = membuf
# then run the command and let the output go into our buffer
- self.onecmd_plus_hooks(history_item)
+ stop = self.onecmd_plus_hooks(history_item)
# rewind the buffer to the beginning
membuf.seek(0)
# get the output out of the buffer
output = membuf.read()
# and add the regex-escaped output to the transcript
transcript += output.replace('/', r'\/')
+ # check if we are supposed to stop
+ if stop:
+ break
finally:
with self.sigint_protection:
# Restore altered attributes to their original state