from __future__ import annotations

import argparse
import subprocess
import sys
from pathlib import Path


def main() -> None:
    parser = argparse.ArgumentParser(description="Score a predictions JSON file with the evaluator shipped in this unpacked benchmark pack.")
    parser.add_argument("--predictions", default="eval/sample_predictions.json", help="Path to predictions JSON relative to the pack root.")
    parser.add_argument("--output", help="Optional JSON report output path.")
    parser.add_argument("--write-markdown", help="Optional Markdown report output path.")
    parser.add_argument("--write-html", help="Optional HTML report output path.")
    args = parser.parse_args()

    pack_root = Path(__file__).resolve().parents[2]
    evaluate_script = pack_root / "eval" / "evaluate.py"
    command = [
        sys.executable,
        str(evaluate_script),
        "--predictions",
        args.predictions,
        "--pack-path",
        ".",
    ]
    if args.output:
        command.extend(["--output", args.output])
    if args.write_markdown:
        command.extend(["--write-markdown", args.write_markdown])
    if args.write_html:
        command.extend(["--write-html", args.write_html])
    raise SystemExit(subprocess.call(command, cwd=pack_root))


if __name__ == "__main__":
    main()
