diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-05-24 13:56:52 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-05-24 13:56:52 -0400 |
commit | a37dd5daf8914ce590440c2ccb2cf45e71a4170b (patch) | |
tree | 7877dbc5fee52e7377772ab853222d68dd4d1d67 | |
parent | ba4de1da1a7cecaf65c264b31528b82183daacbb (diff) | |
download | cmd2-git-a37dd5daf8914ce590440c2ccb2cf45e71a4170b.tar.gz |
Fixed count in output message printed after transcript generation
-rw-r--r-- | cmd2/cmd2.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index 8911a188..6efdda2c 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -3457,6 +3457,7 @@ class Cmd(cmd.Cmd): traceback_war=False) return + commands_run = 0 try: with self.sigint_protection: # Disable echo while we manually redirect stdout to a StringIO buffer @@ -3490,14 +3491,18 @@ class Cmd(cmd.Cmd): # of the command membuf = io.StringIO() self.stdout = membuf + # then run the command and let the output go into our buffer stop = self.onecmd_plus_hooks(history_item) + commands_run += 1 + # 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 @@ -3515,12 +3520,12 @@ class Cmd(cmd.Cmd): self.perror('Failed to save transcript: {}'.format(ex), traceback_war=False) else: # and let the user know what we did - if len(history) > 1: + if commands_run > 1: plural = 'commands and their outputs' else: plural = 'command and its output' msg = '{} {} saved to transcript file {!r}' - self.pfeedback(msg.format(len(history), plural, transcript_file)) + self.pfeedback(msg.format(commands_run, plural, transcript_file)) edit_description = ("Edit a file in a text editor\n" "\n" |