#!/usr/bin/env python3
"""Regenerate cached AI texts (motivation, roast)."""

from __future__ import annotations

import argparse
import asyncio

from server.ai import generate_daily_motivation, generate_roast_of_the_day
from server.config_loader import load_meds_config
from server.db import get_db


async def main() -> None:
    parser = argparse.ArgumentParser(description="Regenerate cached AI texts")
    parser.add_argument("--force", action="store_true", help="Regenerate even if cache exists")
    args = parser.parse_args()

    config = load_meds_config()
    db = await get_db()
    try:
        motivation = await generate_daily_motivation(db, config.timezone, force=args.force)
        roast = await generate_roast_of_the_day(db, config.timezone, force=args.force)
        print("motivation:", motivation)
        print("roast:", roast)
    finally:
        await db.close()


if __name__ == "__main__":
    asyncio.run(main())
