Repository: python-cmd2/cmd2
Pull request #1101 (2021-04-30 17:24:33)

do_eof() now just calls the quit function
This is for convenience in case programs override quit.

codecov[bot]: # [Codecov](https://codecov.io/gh/python-cmd2/cmd2/pull/1101?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-cmd2) Report
> Merging [#1101](https://codecov.io/gh/python-cmd2/cmd2/pull/1101?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-cmd2) (0c6fca5) into [master](https://codecov.io/gh/python-cmd2/cmd2/commit/79bf87d1e333ea5fe0dfeb61c707eb9bddfd0255?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-cmd2) (79bf87d) will **decrease** coverage by `4.38%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/python-cmd2/cmd2/pull/1101/graphs/tree.svg?width=650&height=150&src=pr&token=eks2PUwa6A&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-cmd2)](https://codecov.io/gh/python-cmd2/cmd2/pull/1101?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-cmd2)

```diff
@@            Coverage Diff             @@
##           master    #1101      +/-   ##
==========================================
- Coverage   98.48%   94.10%   -4.39%     
==========================================
  Files          22       22              
  Lines        4746     4747       +1     
==========================================
- Hits         4674     4467     -207     
- Misses         72      280     +208     
```


| [Impacted Files](https://codecov.io/gh/python-cmd2/cmd2/pull/1101?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-cmd2) | Coverage Δ | |
|---|---|---|
| [cmd2/cmd2.py](https://codecov.io/gh/python-cmd2/cmd2/pull/1101/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-cmd2#diff-Y21kMi9jbWQyLnB5) | `90.72% <100.00%> (-7.67%)` | :arrow_down: |
| [cmd2/command\_definition.py](https://codecov.io/gh/python-cmd2/cmd2/pull/1101/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-cmd2#diff-Y21kMi9jb21tYW5kX2RlZmluaXRpb24ucHk=) | `34.54% <0.00%> (-65.46%)` | :arrow_down: |
| [cmd2/decorators.py](https://codecov.io/gh/python-cmd2/cmd2/pull/1101/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-cmd2#diff-Y21kMi9kZWNvcmF0b3JzLnB5) | `97.39% <0.00%> (-2.61%)` | :arrow_down: |
| [cmd2/argparse\_completer.py](https://codecov.io/gh/python-cmd2/cmd2/pull/1101/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-cmd2#diff-Y21kMi9hcmdwYXJzZV9jb21wbGV0ZXIucHk=) | `99.68% <0.00%> (-0.32%)` | :arrow_down: |
| [cmd2/utils.py](https://codecov.io/gh/python-cmd2/cmd2/pull/1101/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-cmd2#diff-Y21kMi91dGlscy5weQ==) | `97.69% <0.00%> (-0.24%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/python-cmd2/cmd2/pull/1101?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-cmd2).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-cmd2)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/python-cmd2/cmd2/pull/1101?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-cmd2). Last update [79bf87d...0c6fca5](https://codecov.io/gh/python-cmd2/cmd2/pull/1101?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-cmd2). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-cmd2).


Patch:
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index 418f8a4f..77f20b71 100644
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -3684,15 +3684,20 @@ 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 with no arguments.
+        This can be overridden if quit should be called differently.
+        """
+        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/docs/features/redirection.rst b/docs/features/redirection.rst
index 677c573d..c7d0ea98 100644
--- a/docs/features/redirection.rst
+++ b/docs/features/redirection.rst
@@ -64,6 +64,7 @@ Disabling Redirection
        from cmd2 import Cmd
        class App(Cmd):
            def __init__(self):
+               super().__init__()
                self.allow_redirection = False
 
    cmd2's parser will still treat the ``>``, ``>>``, and `|` symbols as output


Test patch:
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):