#!/usr/bin/env bash
# Runs the same fmt and clippy checks CI runs (see .github/workflows/ci.yml).
# Install with: git config core.hooksPath .githooks
# Bypass with: git commit --no-verify (not recommended)

set -euo pipefail

if ! command -v cargo >/dev/null 2>&1; then
    echo "pre-commit: cargo not found on PATH; skipping checks" >&2
    exit 0
fi

echo "pre-commit: cargo fmt --check"
cargo fmt --check

echo "pre-commit: cargo clippy -- -D warnings"
cargo clippy --quiet -- -D warnings
