-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall
More file actions
executable file
·73 lines (61 loc) · 1.97 KB
/
Copy pathinstall
File metadata and controls
executable file
·73 lines (61 loc) · 1.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
#!/bin/sh
# CodeStrain installer. Source: https://github.com/codestrain/codestrain-cli/blob/main/install.sh
# Usage: curl -fsSL codestrain.dev/install | sh
# Env: CODESTRAIN_VERSION=0.1.0 (default: latest)
set -eu
PKG="codestrain"
VERSION="${CODESTRAIN_VERSION:-}"
say() { printf '%s\n' "codestrain: $*" >&2; }
fail() { say "error: $*"; exit 1; }
have() { command -v "$1" >/dev/null 2>&1; }
check_python() {
have python3 || fail "python3 not found. Install Python 3.9+ first."
python3 - <<'PY' || fail "Python 3.9+ required (you have $(python3 --version 2>&1))."
import sys
sys.exit(0 if sys.version_info >= (3, 9) else 1)
PY
}
spec() {
if [ -n "$VERSION" ]; then
printf '%s==%s' "$PKG" "$VERSION"
else
printf '%s' "$PKG"
fi
}
path_hint() {
case ":${PATH:-}:" in
*":$HOME/.local/bin:"*) : ;;
*) say "note: add \$HOME/.local/bin to PATH so the 'codestrain' command is found." ;;
esac
}
main() {
pkg="$(spec)"
# Preference order:
# macOS with brew → brew tap (clean PATH, native macOS conventions)
# pipx → isolated venv + ~/.local/bin symlink
# uv tool → fastest, same outcome as pipx
# pip --user → fallback, requires manual PATH hint
if [ "$(uname -s)" = "Darwin" ] && have brew; then
say "installing $pkg via Homebrew"
if ! brew tap | grep -q '^codestrain/tap$'; then
brew tap codestrain/tap
fi
brew install --quiet codestrain/tap/codestrain
say "done. Run: codestrain --help"
return
fi
check_python
if have pipx; then
say "installing $pkg via pipx"
pipx install --force "$pkg"
elif have uv; then
say "installing $pkg via uv tool"
uv tool install --force "$pkg"
else
say "installing $pkg via pip --user (pipx/uv not found)"
python3 -m pip install --user --upgrade "$pkg"
path_hint
fi
say "done. Run: codestrain --help"
}
main