summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd2/cmd2.py11
-rwxr-xr-xtests/test_cmd2.py2
2 files changed, 7 insertions, 6 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index 418f8a4f..0a70e803 100644
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -3684,15 +3684,16 @@ class Cmd(cmd.Cmd):
eof_parser = DEFAULT_ARGUMENT_PARSER(description="Called when Ctrl-D is pressed", epilog=INTERNAL_COMMAND_EPILOG)
@with_argparser(eof_parser)
- def do_eof(self, _: argparse.Namespace) -> bool:
- """Called when Ctrl-D is pressed"""
- # Return True to stop the command loop
- return True
+ def do_eof(self, _: argparse.Namespace) -> Optional[bool]:
+ """Called when Ctrl-D is pressed and calls quit"""
+ self.poutput()
+ # noinspection PyTypeChecker
+ return self.do_quit('')
quit_parser = DEFAULT_ARGUMENT_PARSER(description="Exit this application")
@with_argparser(quit_parser)
- def do_quit(self, _: argparse.Namespace) -> bool:
+ def do_quit(self, _: argparse.Namespace) -> Optional[bool]:
"""Exit this application"""
# Return True to stop the command loop
return True
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index cfa30830..49d90dac 100755
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -972,7 +972,7 @@ def test_ctrl_c_at_prompt(say_app):
# And verify the expected output to stdout
out = say_app.stdout.getvalue()
- assert out == 'hello\n^C\ngoodbye\n'
+ assert out == 'hello\n^C\ngoodbye\n\n'
class ShellApp(cmd2.Cmd):