#!/bin/bash
# Detect if a crate is a filtered-out stub (no real source code)
# Usage: is-stub.sh <crate-dir>
# Exit 0 if stub, 1 if real crate

crate_dir="$1"

if [ -z "$crate_dir" ] || [ ! -d "$crate_dir" ]; then
    echo "Error: Invalid crate directory" >&2
    exit 2
fi

# Find any source file with non-whitespace content
has_code=$(find "$crate_dir" -type f \( \
    -name '*.rs' -o -name '*.c' -o -name '*.h' \
    -o -name '*.cpp' -o -name '*.cc' -o -name '*.go' -o -name '*.py' \) \
    -exec grep -Ilq '[^[:space:]]' {} \; -print -quit)

if [ -z "$has_code" ]; then
    # No source files with content = stub
    exit 0
else
    # Has real code
    exit 1
fi
