mirror of
https://github.com/jeertmans/manim-slides.git
synced 2025-05-20 12:05:56 +08:00
chore(lib): re-organizing the module
This PR refactors a lot of the code in order to have a better organized codebase. If will that I needed to create a second level of submodules, to better distinguish the different parts of this project.
This commit is contained in:
55
manim_slides/cli/render/commands.py
Normal file
55
manim_slides/cli/render/commands.py
Normal file
@ -0,0 +1,55 @@
|
||||
"""Manim Slides' rendering commands."""
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import click
|
||||
|
||||
|
||||
@click.command(
|
||||
context_settings=dict(
|
||||
ignore_unknown_options=True, allow_extra_args=True, help_option_names=("-h",)
|
||||
),
|
||||
options_metavar="[-h] [--CE|--GL]",
|
||||
)
|
||||
@click.option(
|
||||
"--CE",
|
||||
is_flag=True,
|
||||
envvar="MANIM_RENDERER",
|
||||
show_envvar=True,
|
||||
help="If set, use Manim Community Edition (CE) renderer. "
|
||||
"If this or ``--GL`` is not set, defaults to CE renderer.",
|
||||
)
|
||||
@click.option(
|
||||
"--GL",
|
||||
is_flag=True,
|
||||
envvar="MANIMGL_RENDERER",
|
||||
show_envvar=True,
|
||||
help="If set, use ManimGL renderer.",
|
||||
)
|
||||
@click.argument("args", metavar="[RENDERER_ARGS]...", nargs=-1, type=click.UNPROCESSED)
|
||||
def render(ce: bool, gl: bool, args: tuple[str, ...]) -> None:
|
||||
"""
|
||||
Render SCENE(s) from the input FILE, using the specified renderer.
|
||||
|
||||
Use ``manim-slides render --help`` to see help information for
|
||||
a specific renderer.
|
||||
|
||||
Alias command to either
|
||||
``manim render [OPTIONS] [ARGS]...`` or
|
||||
``manimgl [OPTIONS] [ARGS]...``.
|
||||
|
||||
This is especially useful for two reasons:
|
||||
|
||||
1. You can are sure to execute the rendering command with the same Python environment
|
||||
as for ``manim-slides``.
|
||||
2. You can pass options to the config.
|
||||
"""
|
||||
if ce and gl:
|
||||
raise click.UsageError("You cannot specify both --CE and --GL renderers.")
|
||||
if gl:
|
||||
subprocess.run([sys.executable, "-m", "manimlib", *args])
|
||||
else:
|
||||
from manim.cli.render.commands import render as render_ce
|
||||
|
||||
render_ce(args, standalone_mode=False)
|
Reference in New Issue
Block a user