mirror of
https://github.com/jeertmans/manim-slides.git
synced 2025-05-23 05:25:54 +08:00

* chore(deps): make Qt backend optional TODO: - [ ] Add relevant entry in CHANGELOG - [ ] Update install documentation - [ ] Make sure `manim-slides convert` can run without any Qt backend - [ ] Make sure test suite works (partially) without any Qt backend - [ ] Make sure we can import `manim_slides` without any Qt backend * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * chore(deps): some fixes but wip * chore(docs): update * chore(deps): support PyQt6 * chore(deps): make Qt backend optional TODO: - [ ] Add relevant entry in CHANGELOG - [ ] Update install documentation - [ ] Make sure `manim-slides convert` can run without any Qt backend - [ ] Make sure test suite works (partially) without any Qt backend - [ ] Make sure we can import `manim_slides` without any Qt backend * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * chore(deps): some fixes but wip * chore(docs): update * chore(deps): support PyQt6 * fix(deps): ci and docs * fix(lib): missing package * chore(ci): does it work? * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * chore(test): skip failing * chore(docs): update * chore(docs): update * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix(docs): typo * fix(test): quit instead of shutdown --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
86 lines
2.3 KiB
Python
86 lines
2.3 KiB
Python
import sys
|
|
from pathlib import Path
|
|
|
|
import click
|
|
|
|
from ..commons import config_options, verbosity_option
|
|
from ..config import Config
|
|
from ..defaults import CONFIG_PATH
|
|
from ..logger import logger
|
|
|
|
|
|
@click.command()
|
|
@config_options
|
|
@click.help_option("-h", "--help")
|
|
@verbosity_option
|
|
def wizard(config_path: Path, force: bool, merge: bool) -> None:
|
|
"""Launch configuration wizard."""
|
|
return _init(config_path, force, merge, skip_interactive=False)
|
|
|
|
|
|
@click.command()
|
|
@config_options
|
|
@click.help_option("-h", "--help")
|
|
@verbosity_option
|
|
def init(
|
|
config_path: Path, force: bool, merge: bool, skip_interactive: bool = False
|
|
) -> None:
|
|
"""Initialize a new default configuration file."""
|
|
return _init(config_path, force, merge, skip_interactive=True)
|
|
|
|
|
|
def _init(
|
|
config_path: Path, force: bool, merge: bool, skip_interactive: bool = False
|
|
) -> None:
|
|
"""
|
|
Actual initialization code for configuration file, with optional interactive
|
|
mode.
|
|
"""
|
|
if config_path.exists():
|
|
click.secho(f"The `{CONFIG_PATH}` configuration file exists")
|
|
|
|
if not force and not merge:
|
|
choice = click.prompt(
|
|
"Do you want to continue and (o)verwrite / (m)erge it, or (q)uit?",
|
|
type=click.Choice(["o", "m", "q"], case_sensitive=False),
|
|
)
|
|
|
|
force = choice == "o"
|
|
merge = choice == "m"
|
|
|
|
if not force and not merge:
|
|
logger.debug("Exiting without doing anything")
|
|
sys.exit(0)
|
|
|
|
config = Config()
|
|
|
|
if force:
|
|
logger.debug(f"Overwriting `{config_path}` if exists")
|
|
elif merge:
|
|
logger.debug("Merging new config into `{config_path}`")
|
|
|
|
if not skip_interactive:
|
|
if config_path.exists():
|
|
config = Config.from_file(config_path)
|
|
|
|
from ..qt_utils import qapp
|
|
from .wizard import Wizard
|
|
|
|
app = qapp()
|
|
app.setApplicationName("Manim Slides Wizard")
|
|
window = Wizard(config)
|
|
window.show()
|
|
app.exec()
|
|
|
|
if window.closed_without_saving:
|
|
sys.exit(0)
|
|
|
|
config = window.config
|
|
|
|
if merge:
|
|
config = Config.from_file(config_path).merge_with(config)
|
|
|
|
config.to_file(config_path)
|
|
|
|
click.secho(f"Configuration file successfully saved to `{config_path}`")
|