#!/bin/sh
#
# Pre-commit hook: Format and lint checks
# Installed by cargo-husky
#

set -e

echo "🔍 Running pre-commit checks..."
echo ""

# Check formatting
echo "📐 Checking formatting (cargo fmt)..."
cargo fmt -- --check
if [ $? -ne 0 ]; then
    echo ""
    echo "❌ Formatting check failed!"
    echo "   Run 'cargo fmt' to fix formatting issues."
    exit 1
fi
echo "✅ Formatting OK"
echo ""

# Run clippy
echo "📎 Running clippy..."
cargo clippy --all-targets --all-features -- -D warnings
if [ $? -ne 0 ]; then
    echo ""
    echo "❌ Clippy found issues!"
    echo "   Fix the warnings above before committing."
    exit 1
fi
echo "✅ Clippy OK"
echo ""

echo "✅ All pre-commit checks passed!"

