#!/usr/bin/env bash
set -e

echo "Running pre-commit checks..."

echo "  cargo fmt --check"
cargo fmt --check || {
    echo "ERROR: cargo fmt check failed. Run 'cargo fmt' to fix formatting."
    exit 1
}

echo "  cargo clippy"
cargo clippy -- -D warnings || {
    echo "ERROR: clippy found warnings. Fix them before committing."
    exit 1
}

echo "  cargo test"
cargo test --quiet || {
    echo "ERROR: tests failed. Fix them before committing."
    exit 1
}

echo "All pre-commit checks passed."
