Skip to content

Commit 7eae458

Browse files
authored
Merge branch 'master' into make-run_editor-public
2 parents 9068f14 + d24f1ad commit 7eae458

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

cmd2/cmd2.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3684,15 +3684,20 @@ def do_shortcuts(self, _: argparse.Namespace) -> None:
36843684
eof_parser = DEFAULT_ARGUMENT_PARSER(description="Called when Ctrl-D is pressed", epilog=INTERNAL_COMMAND_EPILOG)
36853685

36863686
@with_argparser(eof_parser)
3687-
def do_eof(self, _: argparse.Namespace) -> bool:
3688-
"""Called when Ctrl-D is pressed"""
3689-
# Return True to stop the command loop
3690-
return True
3687+
def do_eof(self, _: argparse.Namespace) -> Optional[bool]:
3688+
"""
3689+
Called when Ctrl-D is pressed and calls quit with no arguments.
3690+
This can be overridden if quit should be called differently.
3691+
"""
3692+
self.poutput()
3693+
3694+
# noinspection PyTypeChecker
3695+
return self.do_quit('')
36913696

36923697
quit_parser = DEFAULT_ARGUMENT_PARSER(description="Exit this application")
36933698

36943699
@with_argparser(quit_parser)
3695-
def do_quit(self, _: argparse.Namespace) -> bool:
3700+
def do_quit(self, _: argparse.Namespace) -> Optional[bool]:
36963701
"""Exit this application"""
36973702
# Return True to stop the command loop
36983703
return True

docs/features/redirection.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ Disabling Redirection
6464
from cmd2 import Cmd
6565
class App(Cmd):
6666
def __init__(self):
67+
super().__init__()
6768
self.allow_redirection = False
6869

6970
cmd2's parser will still treat the ``>``, ``>>``, and `|` symbols as output

tests/test_cmd2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,7 @@ def test_ctrl_c_at_prompt(say_app):
972972

973973
# And verify the expected output to stdout
974974
out = say_app.stdout.getvalue()
975-
assert out == 'hello\n^C\ngoodbye\n'
975+
assert out == 'hello\n^C\ngoodbye\n\n'
976976

977977

978978
class ShellApp(cmd2.Cmd):

0 commit comments

Comments
 (0)