"""cf export-xlsx — экспорт модели в Excel.""" import typer from infrastructure.cli.i18n import t from infrastructure.cli.paths import EXPORTS_DIR from infrastructure.cli.services import console, load_model from infrastructure.repositories import ExcelRepository, ExcelRepositoryError _repo = ExcelRepository() # Значение по умолчанию остаётся ровно "exports/forecast.xlsx" (строка в help # и в аргументе CLI не меняется) — собирается из EXPORTS_DIR во избежание # дублирования литерала пути. DEFAULT_EXPORT_PATH: str = str(EXPORTS_DIR / "forecast.xlsx") def export_xlsx( path: str = typer.Argument(DEFAULT_EXPORT_PATH, help=t("cmd.export.arg.path")), ) -> None: """Экспорт модели в Excel""" model = load_model() try: _repo.save(model, path) console.print(t("cmd.export.ok", path=path)) except ExcelRepositoryError as e: console.print(f"[red]{t('cmd.export.err', error=str(e))}[/red]") raise typer.Exit(1)