prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Feature request: optionally suppress "Manim Comunity v{version}"
  ## Description of proposed feature
  
  Hello! As of recent versions of Manim, it is not possible to suppress the `Manim Community v{version}` message that is printed out when importing `manim`.
  
  Actually, this is because importing `manim` imports `manim.__init__`, which in turn imports `manim.__main__` with this: https://github.com/ManimCommunity/manim/blob/88836df8ab1ea153ed57848a74a694c517962163/manim/__init__.py#L104-L113
  
  Before, I could suppress the message using some redirect, but now if fails
  
  ```python
  >>> import os
  >>> from contextlib import redirect_stdout
  >>> 
  >>> with redirect_stdout(open(os.devnull, "w")):
  >>>     print("HELLO")
  >>>     import manim
  Manim Community v0.17.2
  ```
  because Rich will still print to `stdout` (since the console was created before `stdout` was redirected). 
  
  Rich's console has an optional `file` argument, but there currently seem to be a bug with it, reported in https://github.com/Textualize/rich/issues/3083, that makes Rich's consoles only print to stdout.
  
  A **nice feature** would be to make the behavior optional.
  
  ## How can the new feature be used?
  
  There are a few possible solutions:
  
  - Not printing the version at all;
  - Moving the print message inside the `__main__`:
  https://github.com/ManimCommunity/manim/blob/88836df8ab1ea153ed57848a74a694c517962163/manim/__main__.py#L59-L60
  - Optionally print (or disable print) with some environ variable
  - ...
  
  ## Additional comments
  
  I develop Manim Slides, a Manim plugin, and I'd like to avoid printing the Manim Community version every time I import this package, because the user does not really need to know that.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `manim/__main__.py`
  Content:
  ```
  1 from __future__ import annotations
  2 
  3 import sys
  4 
  5 import cloup
  6 
  7 from . import __version__, cli_ctx_settings, console
  8 from .cli.cfg.group import cfg
  9 from .cli.checkhealth.commands import checkhealth
  10 from .cli.default_group import DefaultGroup
  11 from .cli.init.commands import init
  12 from .cli.plugins.commands import plugins
  13 from .cli.render.commands import render
  14 from .constants import EPILOG
  15 
  16 
  17 def exit_early(ctx, param, value):
  18     if value:
  19         sys.exit()
  20 
  21 
  22 console.print(f"Manim Community [green]v{__version__}[/green]\n")
  23 
  24 
  25 @cloup.group(
  26     context_settings=cli_ctx_settings,
  27     cls=DefaultGroup,
  28     default="render",
  29     no_args_is_help=True,
  30     help="Animation engine for explanatory math videos.",
  31     epilog="See 'manim <command>' to read about a specific subcommand.\n\n"
  32     "Note: the subcommand 'manim render' is called if no other subcommand "
  33     "is specified. Run 'manim render --help' if you would like to know what the "
  34     f"'-ql' or '-p' flags do, for example.\n\n{EPILOG}",
  35 )
  36 @cloup.option(
  37     "--version",
  38     is_flag=True,
  39     help="Show version and exit.",
  40     callback=exit_early,
  41     is_eager=True,
  42     expose_value=False,
  43 )
  44 @cloup.pass_context
  45 def main(ctx):
  46     """The entry point for manim."""
  47     pass
  48 
  49 
  50 main.add_command(checkhealth)
  51 main.add_command(cfg)
  52 main.add_command(plugins)
  53 main.add_command(init)
  54 main.add_command(render)
  55 
  56 if __name__ == "__main__":
  57     main()
  58
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/manim/__main__.py b/manim/__main__.py
  --- a/manim/__main__.py
  +++ b/manim/__main__.py
  @@ -2,6 +2,7 @@
   
   import sys
   
  +import click
   import cloup
   
   from . import __version__, cli_ctx_settings, console
  @@ -14,12 +15,15 @@
   from .constants import EPILOG
   
   
  -def exit_early(ctx, param, value):
  +def show_splash(ctx, param, value):
       if value:
  -        sys.exit()
  +        console.print(f"Manim Community [green]v{__version__}[/green]\n")
   
   
  -console.print(f"Manim Community [green]v{__version__}[/green]\n")
  +def print_version_and_exit(ctx, param, value):
  +    show_splash(ctx, param, value)
  +    if value:
  +        ctx.exit()
   
   
   @cloup.group(
  @@ -37,7 +41,16 @@
       "--version",
       is_flag=True,
       help="Show version and exit.",
  -    callback=exit_early,
  +    callback=print_version_and_exit,
  +    is_eager=True,
  +    expose_value=False,
  +)
  +@click.option(
  +    "--show-splash/--hide-splash",
  +    is_flag=True,
  +    default=True,
  +    help="Print splash message with version information.",
  +    callback=show_splash,
       is_eager=True,
       expose_value=False,
   )
  
verification_info: {"golden_diff": "diff --git a/manim/__main__.py b/manim/__main__.py\n--- a/manim/__main__.py\n+++ b/manim/__main__.py\n@@ -2,6 +2,7 @@\n \n import sys\n \n+import click\n import cloup\n \n from . import __version__, cli_ctx_settings, console\n@@ -14,12 +15,15 @@\n from .constants import EPILOG\n \n \n-def exit_early(ctx, param, value):\n+def show_splash(ctx, param, value):\n     if value:\n-        sys.exit()\n+        console.print(f\"Manim Community [green]v{__version__}[/green]\\n\")\n \n \n-console.print(f\"Manim Community [green]v{__version__}[/green]\\n\")\n+def print_version_and_exit(ctx, param, value):\n+    show_splash(ctx, param, value)\n+    if value:\n+        ctx.exit()\n \n \n @cloup.group(\n@@ -37,7 +41,16 @@\n     \"--version\",\n     is_flag=True,\n     help=\"Show version and exit.\",\n-    callback=exit_early,\n+    callback=print_version_and_exit,\n+    is_eager=True,\n+    expose_value=False,\n+)\n+@click.option(\n+    \"--show-splash/--hide-splash\",\n+    is_flag=True,\n+    default=True,\n+    help=\"Print splash message with version information.\",\n+    callback=show_splash,\n     is_eager=True,\n     expose_value=False,\n )\n", "issue": "Feature request: optionally suppress \"Manim Comunity v{version}\"\n## Description of proposed feature\r\n\r\nHello! As of recent versions of Manim, it is not possible to suppress the `Manim Community v{version}` message that is printed out when importing `manim`.\r\n\r\nActually, this is because importing `manim` imports `manim.__init__`, which in turn imports `manim.__main__` with this: https://github.com/ManimCommunity/manim/blob/88836df8ab1ea153ed57848a74a694c517962163/manim/__init__.py#L104-L113\r\n\r\nBefore, I could suppress the message using some redirect, but now if fails\r\n\r\n```python\r\n>>> import os\r\n>>> from contextlib import redirect_stdout\r\n>>> \r\n>>> with redirect_stdout(open(os.devnull, \"w\")):\r\n>>>     print(\"HELLO\")\r\n>>>     import manim\r\nManim Community v0.17.2\r\n```\r\nbecause Rich will still print to `stdout` (since the console was created before `stdout` was redirected). \r\n\r\nRich's console has an optional `file` argument, but there currently seem to be a bug with it, reported in https://github.com/Textualize/rich/issues/3083, that makes Rich's consoles only print to stdout.\r\n\r\nA **nice feature** would be to make the behavior optional.\r\n\r\n## How can the new feature be used?\r\n\r\nThere are a few possible solutions:\r\n\r\n- Not printing the version at all;\r\n- Moving the print message inside the `__main__`:\r\nhttps://github.com/ManimCommunity/manim/blob/88836df8ab1ea153ed57848a74a694c517962163/manim/__main__.py#L59-L60\r\n- Optionally print (or disable print) with some environ variable\r\n- ...\r\n\r\n## Additional comments\r\n\r\nI develop Manim Slides, a Manim plugin, and I'd like to avoid printing the Manim Community version every time I import this package, because the user does not really need to know that.\r\n\n", "before_files": [{"content": "from __future__ import annotations\n\nimport sys\n\nimport cloup\n\nfrom . import __version__, cli_ctx_settings, console\nfrom .cli.cfg.group import cfg\nfrom .cli.checkhealth.commands import checkhealth\nfrom .cli.default_group import DefaultGroup\nfrom .cli.init.commands import init\nfrom .cli.plugins.commands import plugins\nfrom .cli.render.commands import render\nfrom .constants import EPILOG\n\n\ndef exit_early(ctx, param, value):\n    if value:\n        sys.exit()\n\n\nconsole.print(f\"Manim Community [green]v{__version__}[/green]\\n\")\n\n\n@cloup.group(\n    context_settings=cli_ctx_settings,\n    cls=DefaultGroup,\n    default=\"render\",\n    no_args_is_help=True,\n    help=\"Animation engine for explanatory math videos.\",\n    epilog=\"See 'manim <command>' to read about a specific subcommand.\\n\\n\"\n    \"Note: the subcommand 'manim render' is called if no other subcommand \"\n    \"is specified. Run 'manim render --help' if you would like to know what the \"\n    f\"'-ql' or '-p' flags do, for example.\\n\\n{EPILOG}\",\n)\n@cloup.option(\n    \"--version\",\n    is_flag=True,\n    help=\"Show version and exit.\",\n    callback=exit_early,\n    is_eager=True,\n    expose_value=False,\n)\n@cloup.pass_context\ndef main(ctx):\n    \"\"\"The entry point for manim.\"\"\"\n    pass\n\n\nmain.add_command(checkhealth)\nmain.add_command(cfg)\nmain.add_command(plugins)\nmain.add_command(init)\nmain.add_command(render)\n\nif __name__ == \"__main__\":\n    main()\n", "path": "manim/__main__.py"}], "after_files": [{"content": "from __future__ import annotations\n\nimport sys\n\nimport click\nimport cloup\n\nfrom . import __version__, cli_ctx_settings, console\nfrom .cli.cfg.group import cfg\nfrom .cli.checkhealth.commands import checkhealth\nfrom .cli.default_group import DefaultGroup\nfrom .cli.init.commands import init\nfrom .cli.plugins.commands import plugins\nfrom .cli.render.commands import render\nfrom .constants import EPILOG\n\n\ndef show_splash(ctx, param, value):\n    if value:\n        console.print(f\"Manim Community [green]v{__version__}[/green]\\n\")\n\n\ndef print_version_and_exit(ctx, param, value):\n    show_splash(ctx, param, value)\n    if value:\n        ctx.exit()\n\n\n@cloup.group(\n    context_settings=cli_ctx_settings,\n    cls=DefaultGroup,\n    default=\"render\",\n    no_args_is_help=True,\n    help=\"Animation engine for explanatory math videos.\",\n    epilog=\"See 'manim <command>' to read about a specific subcommand.\\n\\n\"\n    \"Note: the subcommand 'manim render' is called if no other subcommand \"\n    \"is specified. Run 'manim render --help' if you would like to know what the \"\n    f\"'-ql' or '-p' flags do, for example.\\n\\n{EPILOG}\",\n)\n@cloup.option(\n    \"--version\",\n    is_flag=True,\n    help=\"Show version and exit.\",\n    callback=print_version_and_exit,\n    is_eager=True,\n    expose_value=False,\n)\n@click.option(\n    \"--show-splash/--hide-splash\",\n    is_flag=True,\n    default=True,\n    help=\"Print splash message with version information.\",\n    callback=show_splash,\n    is_eager=True,\n    expose_value=False,\n)\n@cloup.pass_context\ndef main(ctx):\n    \"\"\"The entry point for manim.\"\"\"\n    pass\n\n\nmain.add_command(checkhealth)\nmain.add_command(cfg)\nmain.add_command(plugins)\nmain.add_command(init)\nmain.add_command(render)\n\nif __name__ == \"__main__\":\n    main()\n", "path": "manim/__main__.py"}]}