forked from lorryjovens-hub/claude-code-rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-unix.sh
More file actions
152 lines (125 loc) ยท 3.8 KB
/
install-unix.sh
File metadata and controls
152 lines (125 loc) ยท 3.8 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/bash
# Claude Code Rust ๅฎ่ฃ
่ๆฌ - ๅฎๆด็ (Linux/macOS)
# ็จๆณ: bash install-unix.sh
set -e
# ้ข่ฒๅฎไน
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
print_header() {
echo -e "${BLUE}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ${NC}"
echo -e "${BLUE}$1${NC}"
echo -e "${BLUE}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ${NC}"
}
print_success() {
echo -e "${GREEN}โ $1${NC}"
}
print_error() {
echo -e "${RED}โ $1${NC}"
}
print_warning() {
echo -e "${YELLOW}โ $1${NC}"
}
# ๆฃๆตๆไฝ็ณป็ป
detect_os() {
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
OS="linux"
if [[ $(uname -m) == "aarch64" ]]; then
ARCH="aarch64"
else
ARCH="x86_64"
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
OS="macos"
if [[ $(uname -m) == "arm64" ]]; then
ARCH="aarch64"
else
ARCH="x86_64"
fi
else
print_error "ไธๆฏๆ็ๆไฝ็ณป็ป: $OSTYPE"
exit 1
fi
print_success "ๆฃๆตๅฐๆไฝ็ณป็ป: $OS ($ARCH)"
}
# ้ๆฉๅฎ่ฃ
่ทฏๅพ
choose_install_path() {
echo ""
print_header "้ๆฉๅฎ่ฃ
่ทฏๅพ"
INSTALL_PATHS=()
[[ -w "/usr/local/bin" ]] && INSTALL_PATHS+=("/usr/local/bin")
[[ -w "$HOME/.local/bin" ]] && INSTALL_PATHS+=("$HOME/.local/bin")
INSTALL_PATHS+=("$HOME/bin")
if [[ ${#INSTALL_PATHS[@]} -eq 1 ]]; then
INSTALL_PATH="${INSTALL_PATHS[0]}"
else
echo "้ๆฉๅฎ่ฃ
่ทฏๅพ:"
for i in "${!INSTALL_PATHS[@]}"; do
echo " $((i+1))) ${INSTALL_PATHS[$i]}"
done
read -p "้ๆฉ (1-${#INSTALL_PATHS[@]}): " choice
INSTALL_PATH="${INSTALL_PATHS[$((choice-1))]}"
fi
mkdir -p "$INSTALL_PATH"
print_success "ๅฎ่ฃ
่ทฏๅพ: $INSTALL_PATH"
}
# ่ทๅๆๆฐ็ๆฌ
get_latest_version() {
echo ""
print_header "่ทๅๆๆฐ็ๆฌ"
LATEST_VERSION=$(curl -s https://api.github.com/repos/lorryjovens-hub/claude-code-rust/releases/latest | grep '"tag_name"' | cut -d'"' -f4)
[[ -z "$LATEST_VERSION" ]] && LATEST_VERSION="v0.1.0"
print_success "ๆๆฐ็ๆฌ: $LATEST_VERSION"
}
# ไธ่ฝฝๅนถๅฎ่ฃ
download_and_install() {
echo ""
print_header "ไธ่ฝฝๅนถๅฎ่ฃ
"
BINARY_NAME="claude-code-rust-${OS}-${ARCH}"
DOWNLOAD_URL="https://github.com/lorryjovens-hub/claude-code-rust/releases/download/${LATEST_VERSION}/${BINARY_NAME}"
TEMP_FILE="/tmp/${BINARY_NAME}.tmp"
INSTALL_FILE="$INSTALL_PATH/claude-code-rs"
print_warning "ไธ่ฝฝไธญ: $BINARY_NAME"
if ! curl -fsSL -o "$TEMP_FILE" "$DOWNLOAD_URL"; then
print_error "ไธ่ฝฝๅคฑ่ดฅ"
exit 1
fi
mv "$TEMP_FILE" "$INSTALL_FILE"
chmod +x "$INSTALL_FILE"
print_success "ๅทฒๅฎ่ฃ
: $INSTALL_FILE"
}
# ้ช่ฏๅฎ่ฃ
verify_installation() {
echo ""
print_header "้ช่ฏๅฎ่ฃ
"
if command -v claude-code-rs &> /dev/null; then
VERSION=$(claude-code-rs --version)
print_success "ๅฎ่ฃ
ๆๅ!"
echo ""
echo "็ๆฌไฟกๆฏ: $VERSION"
echo ""
echo "ๅฟซ้ๅฝไปค:"
echo " claude-code-rs --help"
echo " claude-code-rs --version"
echo " claude-code-rs"
echo ""
print_success "ๅๅคๅฅฝๅผๅงไฝฟ็จไบ!"
else
print_error "้ช่ฏๅคฑ่ดฅ!"
exit 1
fi
}
main() {
clear
print_header "Claude Code Rust ๅฎ่ฃ
็จๅบ"
echo ""
detect_os
choose_install_path
get_latest_version
download_and_install
verify_installation
}
trap 'print_error "ไธญๆญขๅฎ่ฃ
"; rm -f /tmp/claude-code-rust*.tmp; exit 1' INT TERM
main