Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions manim/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import sys

import click
import cloup

from . import __version__, cli_ctx_settings, console
Expand All @@ -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(
Expand All @@ -37,7 +41,16 @@ def exit_early(ctx, param, value):
"--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,
)
Expand Down
12 changes: 9 additions & 3 deletions tests/interface/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ def test_manim_cfg_subcommand():
command = ["cfg"]
runner = CliRunner()
result = runner.invoke(main, command, prog_name="manim")
expected_output = """\
expected_output = f"""\
Manim Community v{__version__}

Usage: manim cfg [OPTIONS] COMMAND [ARGS]...

Manages Manim configuration files.
Expand All @@ -50,7 +52,9 @@ def test_manim_plugins_subcommand():
command = ["plugins"]
runner = CliRunner()
result = runner.invoke(main, command, prog_name="manim")
expected_output = """\
expected_output = f"""\
Manim Community v{__version__}

Usage: manim plugins [OPTIONS]

Manages Manim plugins.
Expand Down Expand Up @@ -90,7 +94,9 @@ def test_manim_init_subcommand():
command = ["init"]
runner = CliRunner()
result = runner.invoke(main, command, prog_name="manim")
expected_output = """\
expected_output = f"""\
Manim Community v{__version__}

Usage: manim init [OPTIONS] COMMAND [ARGS]...

Create a new project or insert a new scene.
Expand Down