#!/bin/sh
# Pre-commit hook for Rust projects via cargo-husky
# Runs cargo fmt and cargo clippy before committing

set -e

echo "Running cargo fmt..."
cargo fmt --all -- --check
if [ $? -ne 0 ]; then
    echo "❌ Code formatting check failed. Please run 'cargo fmt' to fix."
    exit 1
fi

echo "Running cargo clippy..."
cargo clippy --all-targets --all-features -- -D warnings
if [ $? -ne 0 ]; then
    echo "❌ Clippy check failed. Please fix the warnings."
    exit 1
fi

echo "✓ All checks passed!"
exit 0
