Skip to content

Commit 9d7ddf6

Browse files
Frank Guoclaude
andcommitted
feat: improve install script with banner, progress bar, and colors
Add visual banner, step indicators (✓/▸/✗), and curl progress bar for the binary download. Small files stay silent. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 58ffe72 commit 9d7ddf6

1 file changed

Lines changed: 56 additions & 27 deletions

File tree

scripts/install.sh

Lines changed: 56 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,44 @@ if [[ -t 1 ]]; then
1010
GREEN='\033[0;32m'
1111
YELLOW='\033[0;33m'
1212
BLUE='\033[0;34m'
13+
CYAN='\033[0;36m'
14+
DIM='\033[2m'
1315
BOLD='\033[1m'
1416
NC='\033[0m'
1517
else
16-
RED='' GREEN='' YELLOW='' BLUE='' BOLD='' NC=''
18+
RED='' GREEN='' YELLOW='' BLUE='' CYAN='' DIM='' BOLD='' NC=''
1719
fi
1820

19-
info() { printf '%b%s%b\n' "${BLUE}==>${NC} ${BOLD}" "$1" "${NC}"; }
20-
success() { printf '%b%s%b\n' "${GREEN}==>${NC} ${BOLD}" "$1" "${NC}"; }
21-
warn() { printf '%b %s\n' "${YELLOW}Warning:${NC}" "$1"; }
22-
error() { printf '%b %s\n' "${RED}Error:${NC}" "$1" >&2; exit 1; }
21+
info() { printf ' %b%s%b %s\n' "${BLUE}" "" "${NC}" "$1"; }
22+
success() { printf ' %b%s%b %s\n' "${GREEN}" "" "${NC}" "$1"; }
23+
warn() { printf ' %b%s%b %s\n' "${YELLOW}" "!" "${NC}" "$1"; }
24+
error() { printf ' %b%s%b %s\n' "${RED}" "" "${NC}" "$1" >&2; exit 1; }
25+
26+
banner() {
27+
echo ""
28+
printf '%b' "${CYAN}${BOLD}"
29+
echo " ┌─────────────────────────────────┐"
30+
echo " │ rekal installer │"
31+
echo " └─────────────────────────────────┘"
32+
printf '%b' "${NC}"
33+
echo ""
34+
}
35+
36+
# Download with progress bar for interactive terminals, silent otherwise.
37+
download_with_progress() {
38+
local url="$1" dest="$2" label="$3"
39+
info "${label}"
40+
if [[ -t 1 ]]; then
41+
curl -fL --progress-bar "$url" -o "$dest"
42+
else
43+
curl -fsSL "$url" -o "$dest"
44+
fi
45+
}
46+
47+
# Silent download for small files.
48+
download_silent() {
49+
curl -fsSL "$1" -o "$2"
50+
}
2351

2452
detect_os() {
2553
case "$(uname -s | tr '[:upper:]' '[:lower:]')" in
@@ -55,10 +83,6 @@ get_version() {
5583
echo "$version"
5684
}
5785

58-
download_file() {
59-
curl -fsSL "$1" -o "$2"
60-
}
61-
6286
verify_checksum() {
6387
local file="$1" expected="$2" actual
6488
if command -v sha256sum &>/dev/null; then
@@ -73,16 +97,20 @@ verify_checksum() {
7397
}
7498

7599
main() {
100+
banner
101+
76102
command -v curl &>/dev/null || error "curl is required. Install curl and try again."
77103

78104
# Require Claude Code — check binary on PATH or config directory.
79105
if ! command -v claude &>/dev/null && [[ ! -d "${HOME}/.claude" ]]; then
80106
echo ""
81-
echo -e "${RED}Error:${NC} Rekal requires Claude Code, which was not detected on this system."
82-
echo "For the beta release, only Claude Code is supported. Other coding agents will be supported in a future release."
107+
echo -e " ${RED}${NC} Rekal requires Claude Code, which was not detected on this system."
108+
echo " For the beta release, only Claude Code is supported."
109+
echo " Other coding agents will be supported in a future release."
110+
echo ""
111+
echo -e " Install Claude Code: ${BOLD}https://docs.anthropic.com/en/docs/claude-code${NC}"
112+
echo -e " Rekal docs: ${BOLD}https://github.com/rekal-dev/rekal-cli${NC}"
83113
echo ""
84-
echo " Install Claude Code: https://docs.anthropic.com/en/docs/claude-code"
85-
echo " Rekal docs: https://github.com/rekal-dev/rekal-cli"
86114
exit 1
87115
fi
88116

@@ -102,15 +130,14 @@ main() {
102130

103131
local install_dir="${target_dir:-${DEFAULT_INSTALL_DIR}}"
104132

105-
info "Installing Rekal CLI..."
106133
local os arch version
107134
os=$(detect_os)
108135
arch=$(detect_arch)
109-
info "Detected platform: ${os}/${arch}"
136+
success "Platform: ${os}/${arch}"
110137

111138
info "Resolving version..."
112139
version=$(get_version "${version_arg:-}")
113-
info "Version: ${version}"
140+
success "Version: ${BOLD}v${version}${NC}"
114141

115142
local archive_name="rekal_${os}_${arch}.tar.gz"
116143
local download_url="https://github.com/${GITHUB_REPO}/releases/download/v${version}/${archive_name}"
@@ -121,18 +148,17 @@ main() {
121148
REKAL_TMP_DIR="$tmp_dir"
122149
trap 'rm -rf "${REKAL_TMP_DIR:-}"' EXIT
123150

124-
info "Downloading ${archive_name}..."
125-
download_file "$download_url" "${tmp_dir}/${archive_name}" || error "Download failed: $download_url"
151+
echo ""
152+
download_with_progress "$download_url" "${tmp_dir}/${archive_name}" "Downloading ${archive_name}..." \
153+
|| error "Download failed: $download_url"
126154

127-
info "Downloading checksums..."
128-
download_file "$checksums_url" "${tmp_dir}/checksums.txt" || error "Failed to download checksums."
155+
download_silent "$checksums_url" "${tmp_dir}/checksums.txt" || error "Failed to download checksums."
129156

130-
info "Verifying checksum..."
131157
local expected
132158
expected=$(grep -E "${archive_name}\$" "${tmp_dir}/checksums.txt" | awk '{print $1}' || true)
133159
[[ -z "$expected" ]] && error "Checksum for ${archive_name} not found in checksums.txt."
134160
verify_checksum "${tmp_dir}/${archive_name}" "$expected"
135-
success "Checksum OK"
161+
success "Checksum verified"
136162

137163
info "Extracting..."
138164
tar -xzf "${tmp_dir}/${archive_name}" -C "$tmp_dir"
@@ -146,7 +172,8 @@ main() {
146172
mv "$binary_path" "$install_path"
147173

148174
if "$install_path" version &>/dev/null; then
149-
success "Rekal CLI installed to ${install_path}"
175+
echo ""
176+
success "Installed to ${BOLD}${install_path}${NC}"
150177
else
151178
error "Binary failed to run after install."
152179
fi
@@ -155,18 +182,20 @@ main() {
155182
path_binary=$(command -v rekal 2>/dev/null || true)
156183
if [[ -n "$path_binary" && "$path_binary" != "$install_path" ]]; then
157184
echo ""
158-
echo -e "${YELLOW}!${NC} ${BOLD}PATH conflict:${NC} 'rekal' resolves to ${path_binary}, not ${install_path}"
159-
echo -e " Adjust PATH or remove the other binary."
185+
warn "${BOLD}PATH conflict:${NC} 'rekal' resolves to ${path_binary}, not ${install_path}"
186+
echo " Adjust PATH or remove the other binary."
160187
exit 1
161188
fi
162189

163190
if [[ -z "$path_binary" ]]; then
164191
echo ""
165-
echo -e " ${YELLOW}Add to PATH to run \`rekal\` from anywhere:${NC}"
192+
echo -e " ${DIM}Add to PATH to run rekal from anywhere:${NC}"
166193
echo -e " ${BOLD}export PATH=\"${install_dir}:\$PATH\"${NC}"
167194
echo ""
168-
echo " Then run: rekal version"
195+
echo -e " ${DIM}Then run:${NC} ${BOLD}rekal version${NC}"
169196
fi
197+
198+
echo ""
170199
}
171200

172201
main "$@"

0 commit comments

Comments
 (0)