File size: 4,101 Bytes
cc38116
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
# setup_search.sh - Optional search tool setup for GSD
#
# This script checks for and optionally installs search tools.
# GSD works without these tools (falls back to grep), but they improve performance.

set -e

echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " GSD β–Ί Search Tools Setup"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""

# Check for ripgrep
check_ripgrep() {
    if command -v rg &> /dev/null; then
        echo "βœ… ripgrep (rg) is installed: $(rg --version | head -n1)"
        return 0
    else
        echo "❌ ripgrep (rg) is not installed"
        return 1
    fi
}

# Check for fd
check_fd() {
    if command -v fd &> /dev/null; then
        echo "βœ… fd is installed: $(fd --version)"
        return 0
    elif command -v fdfind &> /dev/null; then
        echo "βœ… fd is installed (as fdfind): $(fdfind --version)"
        return 0
    else
        echo "❌ fd is not installed"
        return 1
    fi
}

# Installation suggestions
suggest_install() {
    echo ""
    echo "───────────────────────────────────────────────────────"
    echo "πŸ“¦ Installation Options"
    echo "───────────────────────────────────────────────────────"
    echo ""
    
    # Detect OS
    if [[ "$OSTYPE" == "darwin"* ]]; then
        echo "macOS detected. Install with Homebrew:"
        echo "  brew install ripgrep fd"
    elif [[ -f /etc/debian_version ]]; then
        echo "Debian/Ubuntu detected. Install with apt:"
        echo "  sudo apt install ripgrep fd-find"
        echo "  # Note: fd is installed as 'fdfind' on Debian"
    elif [[ -f /etc/fedora-release ]]; then
        echo "Fedora detected. Install with dnf:"
        echo "  sudo dnf install ripgrep fd-find"
    elif [[ -f /etc/arch-release ]]; then
        echo "Arch Linux detected. Install with pacman:"
        echo "  sudo pacman -S ripgrep fd"
    else
        echo "Install from source or package manager:"
        echo "  ripgrep: https://github.com/BurntSushi/ripgrep"
        echo "  fd: https://github.com/sharkdp/fd"
    fi
    
    echo ""
    echo "───────────────────────────────────────────────────────"
}

# Main
echo "Checking search tools..."
echo ""

RG_OK=0
FD_OK=0

check_ripgrep && RG_OK=1
check_fd && FD_OK=1

echo ""

if [[ $RG_OK -eq 1 && $FD_OK -eq 1 ]]; then
    echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
    echo " βœ… All search tools are ready!"
    echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
    echo ""
    echo "You can use ./scripts/search_repo.sh for optimized searching."
    exit 0
else
    echo "⚠️  Some tools are missing (optional)"
    echo ""
    echo "GSD will work fine with built-in grep, but ripgrep and fd"
    echo "provide faster searching in large codebases."
    
    suggest_install
    
    echo ""
    echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
    echo " GSD β–Ί Using grep as fallback (works fine!)"
    echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
    exit 0
fi