Repository: python-cmd2/cmd2
Pull request #1099 (2021-04-27 19:41:22)

Renamed silent_startup_script to silence_startup_script for clarity

codecov[bot]: # [Codecov](https://codecov.io/gh/python-cmd2/cmd2/pull/1099?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-cmd2) Report
> Merging [#1099](https://codecov.io/gh/python-cmd2/cmd2/pull/1099?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-cmd2) (223f8c5) into [master](https://codecov.io/gh/python-cmd2/cmd2/commit/bdd831681d4b9d4202b15157c801a988ccec33df?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-cmd2) (bdd8316) will **not change** coverage.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/python-cmd2/cmd2/pull/1099/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/1099?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    #1099   +/-   ##
=======================================
  Coverage   98.37%   98.37%           
=======================================
  Files          22       22           
  Lines        4736     4736           
=======================================
  Hits         4659     4659           
  Misses         77       77           
```


| [Impacted Files](https://codecov.io/gh/python-cmd2/cmd2/pull/1099?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/1099/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-cmd2#diff-Y21kMi9jbWQyLnB5) | `98.15% <100.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/python-cmd2/cmd2/pull/1099?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/1099?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-cmd2). Last update [bdd8316...223f8c5](https://codecov.io/gh/python-cmd2/cmd2/pull/1099?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/CHANGELOG.md b/CHANGELOG.md
index 461e48ee..11992122 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,7 @@
     * Removed `--silent` flag from `alias/macro create` since startup scripts can be run silently.
     * Removed `--with_silent` flag from `alias/macro list` since startup scripts can be run silently.
     * Removed `with_argparser_and_unknown_args` since it was deprecated in 1.3.0.
+    * Renamed `silent_startup_script` to `silence_startup_script` for clarity.
     * Replaced `cmd2.Cmd.completion_header` with `cmd2.Cmd.formatted_completions`. See Enhancements
       for description of this new class member.
     * Settables now have new initialization parameters. It is now a required parameter to supply the reference to the
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index 6702d1a7..e5dcca83 100644
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -219,7 +219,7 @@ class Cmd(cmd.Cmd):
         persistent_history_file: str = '',
         persistent_history_length: int = 1000,
         startup_script: str = '',
-        silent_startup_script: bool = False,
+        silence_startup_script: bool = False,
         include_py: bool = False,
         include_ipy: bool = False,
         allow_cli_args: bool = True,
@@ -241,8 +241,8 @@ class Cmd(cmd.Cmd):
         :param persistent_history_length: max number of history items to write
                                           to the persistent history file
         :param startup_script: file path to a script to execute at startup
-        :param silent_startup_script: if ``True``, then the startup script's output will be
-                                      suppressed. Anything written to stderr will still display.
+        :param silence_startup_script: if ``True``, then the startup script's output will be
+                                       suppressed. Anything written to stderr will still display.
         :param include_py: should the "py" command be included for an embedded Python shell
         :param include_ipy: should the "ipy" command be included for an embedded IPython shell
         :param allow_cli_args: if ``True``, then :meth:`cmd2.Cmd.__init__` will process command
@@ -398,7 +398,7 @@ class Cmd(cmd.Cmd):
             startup_script = os.path.abspath(os.path.expanduser(startup_script))
             if os.path.exists(startup_script):
                 script_cmd = f"run_script {utils.quote_string(startup_script)}"
-                if silent_startup_script:
+                if silence_startup_script:
                     script_cmd += f" {constants.REDIRECTION_OUTPUT} {os.devnull}"
                 self._startup_commands.append(script_cmd)
 
diff --git a/docs/features/startup_commands.rst b/docs/features/startup_commands.rst
index f105054b..951e7fff 100644
--- a/docs/features/startup_commands.rst
+++ b/docs/features/startup_commands.rst
@@ -65,10 +65,10 @@ This text file should contain a :ref:`Command Script
 <features/scripting:Command Scripts>`. See the AliasStartup_ example for a
 demonstration.
 
-You can silence a startup script's output by setting ``silent_startup_script``
+You can silence a startup script's output by setting ``silence_startup_script``
 to True::
 
-    cmd2.Cmd.__init__(self, startup_script='.cmd2rc', silent_startup_script=True)
+    cmd2.Cmd.__init__(self, startup_script='.cmd2rc', silence_startup_script=True)
 
 Anything written to stderr will still print. Additionally, a startup script
 cannot be silenced if ``allow_redirection`` is False since silencing works


Test patch:
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index fb4c9d76..b09141c9 100755
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -2667,17 +2667,17 @@ def test_disabled_message_command_name(disable_commands_app):
     assert err[0].startswith('has_helper_funcs is currently disabled')
 
 
-@pytest.mark.parametrize('silent_startup_script', [True, False])
-def test_startup_script(request, capsys, silent_startup_script):
+@pytest.mark.parametrize('silence_startup_script', [True, False])
+def test_startup_script(request, capsys, silence_startup_script):
     test_dir = os.path.dirname(request.module.__file__)
     startup_script = os.path.join(test_dir, '.cmd2rc')
-    app = cmd2.Cmd(allow_cli_args=False, startup_script=startup_script, silent_startup_script=silent_startup_script)
+    app = cmd2.Cmd(allow_cli_args=False, startup_script=startup_script, silence_startup_script=silence_startup_script)
     assert len(app._startup_commands) == 1
     app._startup_commands.append('quit')
     app.cmdloop()
 
     out, err = capsys.readouterr()
-    if silent_startup_script:
+    if silence_startup_script:
         assert not out
     else:
         assert out