""" scripts/enrich_report.py — CLI wrapper for the markdown enricher. Usage: python -m scripts.enrich_report [-o ] If `-o` is omitted, writes alongside the input as `.enriched.md`. Prints a one-line summary of artifact counts to stdout on success. """ from __future__ import annotations import argparse import sys from pathlib import Path # Allow running both as `python -m scripts.enrich_report` and as a plain # script from the vulnforge/ folder. sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) from utils.enricher import enrich_markdown # noqa: E402 def main() -> int: p = argparse.ArgumentParser(description="Enrich a markdown report with clickable artifact links.") p.add_argument("input", type=Path, help="Path to the input markdown file.") p.add_argument( "-o", "--output", type=Path, default=None, help="Output path. Defaults to .enriched.md alongside the input.", ) args = p.parse_args() src: Path = args.input if not src.is_file(): print(f"error: {src} does not exist or is not a file", file=sys.stderr) return 2 dst: Path = args.output or src.with_suffix(".enriched.md") text = src.read_text(encoding="utf-8") enriched, stats = enrich_markdown(text) dst.write_text(enriched, encoding="utf-8") summary = ", ".join(f"{k}={v}" for k, v in stats.as_summary().items() if v) print(f"wrote {dst} ({summary or 'no artifacts found'})") return 0 if __name__ == "__main__": raise SystemExit(main())