D3: убрать мёртвые typer.Typer() из 9 модулей команд

Регистрация CLI идёт через infrastructure/cli/app.py:30-38, где вешается
«сырая» функция. Поэтому в каждом из 9 одно-командных модулей стоял свой
typer.Typer() с декоратором @app.command() — регистрация, которая никогда
не читалась. Убраны:

  commands/analyze.py, compare.py, export_xlsx.py, forecast.py,
  import_xlsx.py, info.py, init.py, scenario.py, whatif.py

commands/config_cmd.py НЕ тронут: его app — настоящий sub-typer,
регистрируемый в app.py:41.

Страховка (написана и проверена ДО правки, проходит и после):
- новый tests/test_cli_contract.py — инвариант поверхности CLI: 9 команд
  верхнего уровня + 19 подкоманд config, у каждой leaf-команды есть
  callback, дефолт export-xlsx = "exports/forecast.xlsx". Тест защищает
  и будущий рефакторинг D25 (разбиение config_cmd.py на пакет).
- сверка вывода `cf --help`, `cf config --help`, `cf export-xlsx --help`,
  `cf forecast --help` с pristine-копией HEAD — побайтово идентично.

Проверка: 81/81 тестов зелёные (75 + 6 новых), ruff check . — All checks passed.
This commit is contained in:
oqyude committed 2026-10-23 18:29:49 +03:00
1 parent 8af1d9a010
commit f66a762796
10 files changed
+94 -27

No files matched your search

-3
View File
@@ -4,12 +4,9 @@ import typer
from infrastructure.cli.i18n import t
from infrastructure.cli.services import build_services, console, load_model, resolve_currency
app = typer.Typer()
CURRENCY_OPTION = typer.Option(None, "--currency", "-c", help=t("cmd.forecast.opt.currency"))
@app.command()
def analyze(
months: int = typer.Option(12, "--months", "-m", help=t("cmd.analyze.opt.months")),
currency: str | None = CURRENCY_OPTION,
-3
View File
@@ -12,12 +12,9 @@ from infrastructure.cli.services import (
resolve_currency,
)
app = typer.Typer()
CURRENCY_OPTION = typer.Option(None, "--currency", "-c", help=t("cmd.forecast.opt.currency"))
@app.command()
def compare(
months: int = typer.Option(12, "--months", "-m", help=t("cmd.compare.opt.months")),
currency: str | None = CURRENCY_OPTION,
@@ -5,11 +5,9 @@ from infrastructure.cli.i18n import t
from infrastructure.cli.services import console, load_model
from infrastructure.repositories import ExcelRepository, ExcelRepositoryError
app = typer.Typer()
_repo = ExcelRepository()
@app.command(name="export-xlsx")
def export_xlsx(
path: str = typer.Argument("exports/forecast.xlsx", help=t("cmd.export.arg.path")),
) -> None:
-3
View File
@@ -12,12 +12,9 @@ from infrastructure.cli.services import (
resolve_currency,
)
app = typer.Typer()
CURRENCY_OPTION = typer.Option(None, "--currency", "-c", help=t("cmd.forecast.opt.currency"))
@app.command()
def forecast(
months: int = typer.Option(12, "--months", "-m", help=t("cmd.forecast.opt.months")),
currency: str | None = CURRENCY_OPTION,
@@ -5,11 +5,9 @@ from infrastructure.cli.i18n import t
from infrastructure.cli.services import console, save_model
from infrastructure.repositories import ExcelRepository, ExcelRepositoryError
app = typer.Typer()
_repo = ExcelRepository()
@app.command(name="import-xlsx")
def import_xlsx(
path: str = typer.Argument(..., help=t("cmd.import.arg.path")),
) -> None:
-4
View File
@@ -1,15 +1,11 @@
"""cf info — сводка всей финансовой модели."""
import typer
from rich.table import Table
from domain import CurrencyConverter
from infrastructure.cli.i18n import t
from infrastructure.cli.services import console, load_model
app = typer.Typer()
@app.command()
def info() -> None:
"""Сводка всей финансовой модели"""
model = load_model()
-4
View File
@@ -1,15 +1,11 @@
"""cf init — создать пустую модель."""
import typer
from domain import FinancialModel
from infrastructure.cli.i18n import t
from infrastructure.cli.paths import MODEL_PATH
from infrastructure.cli.services import console, save_model
app = typer.Typer()
@app.command()
def init() -> None:
"""Создать пустую финансовую модель"""
model = FinancialModel()
-3
View File
@@ -12,12 +12,9 @@ from infrastructure.cli.services import (
resolve_currency,
)
app = typer.Typer()
CURRENCY_OPTION = typer.Option(None, "--currency", "-c", help=t("cmd.forecast.opt.currency"))
@app.command()
def scenario(
name: str = typer.Argument("baseline", help=t("cmd.scenario.arg.name")),
months: int = typer.Option(12, "--months", "-m", help=t("cmd.scenario.opt.months")),
-3
View File
@@ -11,12 +11,9 @@ from infrastructure.cli.services import (
resolve_currency,
)
app = typer.Typer()
CURRENCY_OPTION = typer.Option(None, "--currency", "-c", help=t("cmd.forecast.opt.currency"))
@app.command()
def whatif(
income: float = typer.Option(1.0, "--income", "-i", help=t("cmd.whatif.opt.income")),
expense: float = typer.Option(1.0, "--expense", "-e", help=t("cmd.whatif.opt.expense")),