#!/bin/sh
# MessageFoundry pre-commit checks — generated by the VS Code extension.
# Runs `messagefoundry check` so a commit can't introduce a broken config.
# Bypass once with: git commit --no-verify

PY=python
command -v python >/dev/null 2>&1 || PY=python3
if ! command -v "$PY" >/dev/null 2>&1; then
  echo "MessageFoundry: python not found; skipping checks." >&2
  exit 0
fi

# Prefer a project virtualenv if present (Windows + POSIX layouts).
if [ -x ".venv/Scripts/python.exe" ]; then
  PY=".venv/Scripts/python.exe"
elif [ -x ".venv/bin/python" ]; then
  PY=".venv/bin/python"
fi

if ! "$PY" -c "import messagefoundry" >/dev/null 2>&1; then
  echo "MessageFoundry: 'messagefoundry' not importable in this environment; skipping checks." >&2
  exit 0
fi

exec "$PY" -m messagefoundry check --config 'samples/config' --messages 'samples/messages'
