GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Revert "feat(cli): better install script output" · yangg/opencode@8bad513

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • install
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎install‎

Copy file name to clipboardExpand all lines: install
+9-117Lines changed: 9 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
set -euo pipefail
33
APP=opencode
44

5-
MUTED='\033[0;2m'
65
RED='\033[0;31m'
6+
GREEN='\033[0;32m'
7+
YELLOW='\033[1;33m'
78
ORANGE='\033[38;2;255;140;0m'
89
NC='\033[0m' # No Color
910

@@ -66,8 +67,8 @@ print_message() {
6667
local color=""
6768

6869
case $level in
69-
info) color="${NC}" ;;
70-
warning) color="${NC}" ;;
70+
info) color="${GREEN}" ;;
71+
warning) color="${YELLOW}" ;;
7172
error) color="${RED}" ;;
7273
esac
7374

@@ -85,110 +86,18 @@ check_version() {
8586
installed_version=$(echo $installed_version | awk '{print $2}')
8687

8788
if [[ "$installed_version" != "$specific_version" ]]; then
88-
print_message info "${MUTED}Installed version: ${NC}$installed_version."
89+
print_message info "Installed version: ${YELLOW}$installed_version."
8990
else
90-
print_message info "${MUTED}Version ${NC}$specific_version${MUTED} already installed"
91+
print_message info "Version ${YELLOW}$specific_version${GREEN} already installed"
9192
exit 0
9293
fi
9394
fi
9495
}
9596

96-
unbuffered_sed() {
97-
if echo | sed -u >/dev/null 2>&1; then
98-
sed -nu "$@"
99-
elif echo | sed -l >/dev/null 2>&1; then
100-
sed -nl "$@"
101-
else
102-
local pad="$(printf "\n%512s" "")"
103-
sed -ne "s/$/\\${pad}/" "$@"
104-
fi
105-
}
106-
107-
print_progress() {
108-
local bytes="$1"
109-
local length="$2"
110-
[ "$length" -gt 0 ] || return 0
111-
112-
local width=50
113-
local percent=$(( bytes * 100 / length ))
114-
[ "$percent" -gt 100 ] && percent=100
115-
local on=$(( percent * width / 100 ))
116-
local off=$(( width - on ))
117-
118-
local full_filled=$(printf "%.0s■" {1..50})
119-
local full_empty=$(printf "%.0s・" {1..50})
120-
121-
printf "\r${ORANGE}%s%s %3d%%${NC}" "${full_filled:0:$on}" "${full_empty:0:$off}" "$percent" >&4
122-
}
123-
124-
download_with_progress() {
125-
local url="$1"
126-
local output="$2"
127-
128-
if [ -t 2 ]; then
129-
exec 4>&2
130-
else
131-
exec 4>/dev/null
132-
fi
133-
134-
local tmp_dir=${TMPDIR:-/tmp}
135-
local basename="${tmp_dir}/opencode_install_$$"
136-
local tracefile="${basename}.trace"
137-
138-
rm -f "$tracefile"
139-
mkfifo "$tracefile"
140-
141-
# Hide cursor
142-
printf "\033[?25l" >&4
143-
144-
trap "trap - RETURN; rm -f \"$tracefile\"; printf '\033[?25h' >&4; exec 4>&-" RETURN
145-
146-
(
147-
curl --trace-ascii "$tracefile" -s -L -o "$output" "$url"
148-
) &
149-
local curl_pid=$!
150-
151-
unbuffered_sed \
152-
-e 'y/ACDEGHLNORTV/acdeghlnortv/' \
153-
-e '/^0000: content-length:/p' \
154-
-e '/^<= recv data/p' \
155-
"$tracefile" | \
156-
{
157-
local length=0
158-
local bytes=0
159-
160-
while IFS=" " read -r -a line; do
161-
local tag="${line[0]} ${line[1]}"
162-
163-
if [ "$tag" = "0000: content-length:" ]; then
164-
length="${line[2]}"
165-
length=$(echo "$length" | tr -d '\r')
166-
bytes=0
167-
elif [ "$tag" = "<= recv" ]; then
168-
local size="${line[3]}"
169-
bytes=$(( bytes + size ))
170-
if [ "$length" -gt 0 ]; then
171-
print_progress "$bytes" "$length"
172-
fi
173-
fi
174-
done
175-
}
176-
177-
wait $curl_pid
178-
local ret=$?
179-
echo "" >&4
180-
return $ret
181-
}
182-
18397
download_and_install() {
184-
print_message info "\n${MUTED}Installing ${NC}opencode ${MUTED}version: ${NC}$specific_version"
98+
print_message info "Downloading ${ORANGE}opencode ${GREEN}version: ${YELLOW}$specific_version ${GREEN}..."
18599
mkdir -p opencodetmp && cd opencodetmp
186-
187-
if ! download_with_progress "$url" "$filename"; then
188-
# Fallback to standard curl if custom fails for some reason
189-
curl -# -L -o "$filename" "$url"
190-
fi
191-
100+
curl -# -L -o "$filename" "$url"
192101
unzip -q "$filename"
193102
mv opencode "$INSTALL_DIR"
194103
chmod 755 "${INSTALL_DIR}/opencode"
@@ -208,7 +117,7 @@ add_to_path() {
208117
elif [[ -w $config_file ]]; then
209118
echo -e "\n# opencode" >> "$config_file"
210119
echo "$command" >> "$config_file"
211-
print_message info "${MUTED}Successfully added ${NC}opencode ${MUTED}to \$PATH in ${NC}$config_file"
120+
print_message info "Successfully added ${ORANGE}opencode ${GREEN}to \$PATH in $config_file"
212121
else
213122
print_message warning "Manually add the directory to $config_file (or similar):"
214123
print_message info " $command"
@@ -282,20 +191,3 @@ if [ -n "${GITHUB_ACTIONS-}" ] && [ "${GITHUB_ACTIONS}" == "true" ]; then
282191
echo "$INSTALL_DIR" >> $GITHUB_PATH
283192
print_message info "Added $INSTALL_DIR to \$GITHUB_PATH"
284193
fi
285-
286-
echo -e ""
287-
echo -e "${MUTED}  ${NC} ▄ "
288-
echo -e "${MUTED}█▀▀█ █▀▀█ █▀▀█ █▀▀▄ ${NC}█▀▀▀ █▀▀█ █▀▀█ █▀▀█"
289-
echo -e "${MUTED}█░░█ █░░█ █▀▀▀ █░░█ ${NC}█░░░ █░░█ █░░█ █▀▀▀"
290-
echo -e "${MUTED}▀▀▀▀ █▀▀▀ ▀▀▀▀ ▀ ▀ ${NC}▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀"
291-
echo -e ""
292-
echo -e ""
293-
echo -e "${MUTED}To get started, navigate to a project and run:${NC}"
294-
echo -e "opencode ${MUTED}Use free models${NC}"
295-
echo -e "opencode auth login ${MUTED}Add paid provider API keys${NC}"
296-
echo -e "opencode help ${MUTED}List commands and options${NC}"
297-
echo -e ""
298-
echo -e "${MUTED}For more information visit ${NC}https://opencode.ai/docs"
299-
echo -e ""
300-
echo -e ""
301-

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.