-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·154 lines (136 loc) · 3.97 KB
/
install.sh
File metadata and controls
executable file
·154 lines (136 loc) · 3.97 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
153
154
#!/usr/bin/env bash
#
# Skills CLI Installer for macOS/Linux
#
# Usage:
# curl -fsSL https://raw.githubusercontent.com/kcchien/skills-cli/main/install.sh | bash
#
# Or with custom options:
# curl -fsSL ... | bash -s -- --user # Install to user site-packages
#
set -euo pipefail
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
info() { echo -e "${BLUE}[INFO]${NC} $1"; }
success() { echo -e "${GREEN}[OK]${NC} $1"; }
warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
error() { echo -e "${RED}[ERROR]${NC} $1" >&2; }
# Default values
REPO_URL="https://github.com/kcchien/skills-cli.git"
USER_INSTALL=false
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--user)
USER_INSTALL=true
shift
;;
--repo)
REPO_URL="$2"
shift 2
;;
-h|--help)
echo "Usage: install.sh [OPTIONS]"
echo ""
echo "Options:"
echo " --user Install to user site-packages (no sudo)"
echo " --repo URL Git repository URL"
echo " -h, --help Show this help"
exit 0
;;
*)
error "Unknown option: $1"
exit 1
;;
esac
done
# Header
echo ""
echo " Skills CLI Installer"
echo " ===================="
echo ""
# Check requirements
info "Checking requirements..."
# Check Python
if command -v python3 &>/dev/null; then
PYTHON_VERSION=$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')
PYTHON_MAJOR=$(echo "$PYTHON_VERSION" | cut -d. -f1)
PYTHON_MINOR=$(echo "$PYTHON_VERSION" | cut -d. -f2)
if [[ $PYTHON_MAJOR -lt 3 ]] || [[ $PYTHON_MAJOR -eq 3 && $PYTHON_MINOR -lt 10 ]]; then
error "Python 3.10+ required, found $PYTHON_VERSION"
exit 1
fi
success "Python $PYTHON_VERSION"
else
error "Python 3.10+ is required but not found"
exit 1
fi
# Check Git
if command -v git &>/dev/null; then
GIT_VERSION=$(git --version | awk '{print $3}')
success "Git $GIT_VERSION"
else
error "Git is required but not found"
exit 1
fi
# Check pip
if ! python3 -m pip --version &>/dev/null; then
error "pip is required but not found"
exit 1
fi
# Install via pip
info "Installing skills-cli via pip..."
PIP_ARGS="install --upgrade --no-cache-dir"
if [[ "$USER_INSTALL" == true ]]; then
PIP_ARGS="$PIP_ARGS --user"
fi
if python3 -m pip $PIP_ARGS "git+${REPO_URL}" 2>&1; then
success "Installed successfully"
else
error "Installation failed"
exit 1
fi
# Verify installation
if command -v skills-cli &>/dev/null; then
INSTALLED_PATH=$(command -v skills-cli)
success "Installed to $INSTALLED_PATH"
else
# Check if installed to user bin
USER_BIN="$HOME/.local/bin"
if [[ -f "$USER_BIN/skills-cli" ]]; then
success "Installed to $USER_BIN/skills-cli"
if [[ ":$PATH:" != *":$USER_BIN:"* ]]; then
warn "$USER_BIN is not in PATH"
# Detect shell
SHELL_NAME=$(basename "$SHELL")
case "$SHELL_NAME" in
bash) RC_FILE="$HOME/.bashrc" ;;
zsh) RC_FILE="$HOME/.zshrc" ;;
fish) RC_FILE="$HOME/.config/fish/config.fish" ;;
*) RC_FILE="" ;;
esac
if [[ -n "$RC_FILE" ]] && [[ -f "$RC_FILE" ]]; then
echo "" >> "$RC_FILE"
echo "# Added by skills-cli installer" >> "$RC_FILE"
echo "export PATH=\"\$PATH:$USER_BIN\"" >> "$RC_FILE"
info "Added to $RC_FILE"
warn "Run 'source $RC_FILE' or restart your terminal"
else
warn "Add this to your shell config:"
echo " export PATH=\"\$PATH:$USER_BIN\""
fi
fi
fi
fi
echo ""
success "Installation complete!"
echo ""
echo " Usage:"
echo " skills-cli list"
echo " skills-cli install --all"
echo " skills-cli --help"
echo ""