#!/bin/bash
#
# Find all files implementing a specific requirement
#
# Usage: ./find-req-implementations.sh UR-004
#

if [ $# -eq 0 ]; then
    echo "Usage: $0 <REQUIREMENT_ID>"
    echo "Example: $0 UR-004"
    exit 1
fi

REQ_ID=$1

echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "  Implementations of $REQ_ID"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""

# Full implementations
echo "Full Implementations:"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
grep -rn "@req: $REQ_ID" src-tauri/ src/ 2>/dev/null | \
    grep -v "@req-partial" | \
    grep -v "@req-planned" | \
    sed 's/src-tauri\/src\///' | \
    sed 's/src\///' || echo "  (none)"

echo ""

# Partial implementations
echo "Partial Implementations:"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
grep -rn "@req-partial: $REQ_ID" src-tauri/ src/ 2>/dev/null | \
    sed 's/src-tauri\/src\///' | \
    sed 's/src\///' || echo "  (none)"

echo ""

# Planned
echo "Planned Implementations:"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
grep -rn "@req-planned: $REQ_ID" src-tauri/ src/ 2>/dev/null | \
    sed 's/src-tauri\/src\///' | \
    sed 's/src\///' || echo "  (none)"

echo ""

# Tests
echo "Test Cases:"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
grep -rn "@req-test: $REQ_ID" src-tauri/ 2>/dev/null | \
    sed 's/src-tauri\/src\///' || echo "  (none)"

echo ""
