#!/bin/sh
# Pre-commit hook to run code quality checks

set -e

echo "Running cargo fmt --check..."
cargo fmt --check 2>/dev/null || {
    echo "Error: Code formatting issues found. Run 'cargo fmt' to fix."
    exit 1
}

echo "Running cargo clippy..."
cargo clippy -- -D warnings 2>/dev/null || {
    echo "Error: Clippy warnings found. Please fix them before committing."
    exit 1
}

echo "Running cargo test..."
cargo test 2>/dev/null || {
    echo "Error: Tests failed. Please fix them before committing."
    exit 1
}

echo "All checks passed!"
