summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2021-04-30 13:20:44 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2021-04-30 13:28:50 -0400
commit3e9377adf9ff4b3dc7839d42ff74477627cf5380 (patch)
tree43f9554a1b0fb326d24a5bba45803b59ef8501e0
parent79bf87d1e333ea5fe0dfeb61c707eb9bddfd0255 (diff)
downloadcmd2-git-ctrl-d.tar.gz
do_eof() now just calls the quit functionctrl-d
-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):