#!/usr/bin/env python3
# sloppatrol-scope: all
# sloppatrol-fix: write a hyphen, comma or colon instead. Task content under tasks/ and licence texts are data and are not checked.
"""Written copy (docs, code, workflows) uses no em or en dashes."""

import os
import sys
from pathlib import Path

DASHES = ("–", "—")
SKIP = ("tasks/", "LICENSE")

root = Path(os.environ["SLOPPATROL_ROOT"])
hits = []
for path in Path(os.environ["SLOPPATROL_FILES"]).read_text().splitlines():
    if path.startswith(SKIP) or not path.endswith((".md", ".py", ".toml", ".yml", ".yaml", ".sh")):
        continue
    for number, line in enumerate((root / path).read_text(errors="replace").splitlines(), 1):
        if any(d in line for d in DASHES):
            hits.append(f"{path}:{number}: no-long-dashes an em or en dash in written copy")
print("\n".join(hits)) if hits else None
sys.exit(1 if hits else 0)
