"""cf template-xlsx — создать Excel-шаблон модели для ручного заполнения.""" from pathlib import Path import typer from rich.markup import escape from infrastructure.cli.i18n import t from infrastructure.cli.paths import TEMPLATE_PATH from infrastructure.cli.services import console from infrastructure.repositories import ExcelRepositoryError, write_template app = typer.Typer() @app.command(name="template-xlsx") def template_xlsx( path: Path = typer.Argument(TEMPLATE_PATH, help=t("cmd.template.arg.path")), force: bool = typer.Option(False, "--force", "-f", help=t("cmd.template.opt.force")), ) -> None: """Создать Excel-шаблон для заполнения модели""" if path.exists() and not force: console.print(f"[red]{t('cmd.template.err.exists', path=escape(str(path)))}[/red]") raise typer.Exit(1) try: target = write_template(path, force=force) except ExcelRepositoryError as e: console.print(f"[red]{t('cmd.template.err', error=escape(str(e)))}[/red]") raise typer.Exit(1) console.print(t("cmd.template.ok", path=escape(str(target)))) console.print(t("cmd.template.hint", path=escape(str(target))))