diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2021-04-28 10:41:48 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2021-04-30 13:12:23 -0400 |
commit | 329a2e23bcc65e214e9775bbe995946c407c9629 (patch) | |
tree | cbda7b0153105da4e8304f5fa6950434e8f63bb4 /cmd2/cmd2.py | |
parent | 52aad8b80a619b13a67f9306b621df9c0e02bacf (diff) | |
download | cmd2-git-329a2e23bcc65e214e9775bbe995946c407c9629.tar.gz |
Changed default behavior of runcmds_plus_hooks() to not stop when Ctrl-C is pressed and instead run the next command in its list.
Diffstat (limited to 'cmd2/cmd2.py')
-rw-r--r-- | cmd2/cmd2.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index e5dcca83..3a01abc4 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -2405,7 +2405,7 @@ class Cmd(cmd.Cmd): cmds: Union[List[HistoryItem], List[str]], *, add_to_history: bool = True, - stop_on_keyboard_interrupt: bool = True, + stop_on_keyboard_interrupt: bool = False, ) -> bool: """ Used when commands are being run in an automated fashion like text scripts or history replays. @@ -2413,8 +2413,9 @@ class Cmd(cmd.Cmd): :param cmds: commands to run :param add_to_history: If True, then add these commands to history. Defaults to True. - :param stop_on_keyboard_interrupt: stop command loop if Ctrl-C is pressed instead of just - moving to the next command. Defaults to True. + :param stop_on_keyboard_interrupt: if True, then stop running contents of cmds if Ctrl-C is pressed instead of moving + to the next command in the list. This is used when the commands are part of a + group, like a text script, which should stop upon Ctrl-C. Defaults to False. :return: True if running of commands should stop """ for line in cmds: @@ -4684,7 +4685,7 @@ class Cmd(cmd.Cmd): if args.transcript: self._generate_transcript(script_commands, os.path.expanduser(args.transcript)) else: - return self.runcmds_plus_hooks(script_commands) + return self.runcmds_plus_hooks(script_commands, stop_on_keyboard_interrupt=True) finally: with self.sigint_protection: |