from __future__ import annotations

import argparse
import sys
from pathlib import Path

ROOT_DIR = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(ROOT_DIR))

from app.main import analyze_saved_docx


def main() -> None:
    parser = argparse.ArgumentParser(description="Analyze a DOCX file and generate downloadable reports.")
    parser.add_argument("docx", type=Path, help="Path to the DOCX file.")
    parser.add_argument("--provider", default=None, help="Provider name from configs/api_config.yaml.")
    parser.add_argument("--use-model", action="store_true", help="Call the configured LLM API.")
    args = parser.parse_args()

    result = analyze_saved_docx(args.docx, provider=args.provider, use_model=args.use_model)
    print(f"source: {result['source_filename']}")
    print(f"summary: {result['summary']}")
    print("matched_skills:")
    for skill in result["matched_skills"]:
        print(f"- {skill}")
    print("downloads:")
    print(f"- docx: {result['downloads']['docx']}")
    print(f"- markdown: {result['downloads']['markdown']}")


if __name__ == "__main__":
    main()
