from __future__ import annotations

import argparse
from pathlib import Path

from app.core.heavy_resources import HeavyResourceRegistry


def main() -> int:
    parser = argparse.ArgumentParser(description="Warmup opcional de recursos pesados.")
    parser.add_argument(
        "--resource",
        action="append",
        dest="resources",
        choices=["groq", "gemini", "cie10", "cups", "soat"],
        help="Recurso a precargar. Se puede repetir.",
    )
    args = parser.parse_args()

    base_dir = Path(__file__).resolve().parents[2]
    registry = HeavyResourceRegistry(base_dir)
    results = registry.warmup(*(args.resources or []))
    for name, status in results.items():
        print(f"{name}: {status}")
    return 1 if any(status.startswith("error:") or status == "unknown" for status in results.values()) else 0


if __name__ == "__main__":
    raise SystemExit(main())
