#!/usr/bin/env bash
# Format Rust sources, or check formatting if --check is passed.
# Invoked by: lefthook pre-commit (--check), harness post-edit hooks (apply),
# manual `make fmt` (apply), CI (--check).
set -euo pipefail
case "${1:-apply}" in
  --check) exec cargo fmt -- --check ;;
  apply)   exec cargo fmt ;;
  *) echo "usage: $0 [--check]" >&2; exit 2 ;;
esac
