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 — feat(install): add standard CLI flags (--help, --version, --no-modify… · dkarzon/opencode@10eed6e

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
+79-35Lines changed: 79 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,51 @@ RED='\033[0;31m'
77
ORANGE='\033[38;5;214m'
88
NC='\033[0m' # No Color
99

10+
usage() {
11+
cat <<EOF
12+
OpenCode Installer
13+
14+
Usage: install.sh [options]
15+
16+
Options:
17+
-h, --help Display this help message
18+
-v, --version <version> Install a specific version (e.g., 1.0.180)
19+
--no-modify-path Don't modify shell config files (.zshrc, .bashrc, etc.)
20+
21+
Examples:
22+
curl -fsSL https://opencode.ai/install | bash
23+
curl -fsSL https://opencode.ai/install | bash -s -- --version 1.0.180
24+
EOF
25+
}
26+
1027
requested_version=${VERSION:-}
28+
no_modify_path=false
29+
30+
while [[ $# -gt 0 ]]; do
31+
case "$1" in
32+
-h|--help)
33+
usage
34+
exit 0
35+
;;
36+
-v|--version)
37+
if [[ -n "${2:-}" ]]; then
38+
requested_version="$2"
39+
shift 2
40+
else
41+
echo -e "${RED}Error: --version requires a version argument${NC}"
42+
exit 1
43+
fi
44+
;;
45+
--no-modify-path)
46+
no_modify_path=true
47+
shift
48+
;;
49+
*)
50+
echo -e "${ORANGE}Warning: Unknown option '$1'${NC}" >&2
51+
shift
52+
;;
53+
esac
54+
done
1155

1256
raw_os=$(uname -s)
1357
os=$(echo "$raw_os" | tr '[:upper:]' '[:lower:]')
@@ -304,42 +348,42 @@ case $current_shell in
304348
;;
305349
esac
306350

307-
config_file=""
308-
for file in $config_files; do
309-
if [[ -f $file ]]; then
310-
config_file=$file
311-
break
351+
if [[ "$no_modify_path" != "true" ]]; then
352+
config_file=""
353+
for file in $config_files; do
354+
if [[ -f $file ]]; then
355+
config_file=$file
356+
break
357+
fi
358+
done
359+
360+
if [[ -z $config_file ]]; then
361+
print_message warning "No config file found for $current_shell. You may need to manually add to PATH:"
362+
print_message info " export PATH=$INSTALL_DIR:\$PATH"
363+
elif [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
364+
case $current_shell in
365+
fish)
366+
add_to_path "$config_file" "fish_add_path $INSTALL_DIR"
367+
;;
368+
zsh)
369+
add_to_path "$config_file" "export PATH=$INSTALL_DIR:\$PATH"
370+
;;
371+
bash)
372+
add_to_path "$config_file" "export PATH=$INSTALL_DIR:\$PATH"
373+
;;
374+
ash)
375+
add_to_path "$config_file" "export PATH=$INSTALL_DIR:\$PATH"
376+
;;
377+
sh)
378+
add_to_path "$config_file" "export PATH=$INSTALL_DIR:\$PATH"
379+
;;
380+
*)
381+
export PATH=$INSTALL_DIR:$PATH
382+
print_message warning "Manually add the directory to $config_file (or similar):"
383+
print_message info " export PATH=$INSTALL_DIR:\$PATH"
384+
;;
385+
esac
312386
fi
313-
done
314-
315-
if [[ -z $config_file ]]; then
316-
print_message error "No config file found for $current_shell. Checked files: ${config_files[@]}"
317-
exit 1
318-
fi
319-
320-
if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
321-
case $current_shell in
322-
fish)
323-
add_to_path "$config_file" "fish_add_path $INSTALL_DIR"
324-
;;
325-
zsh)
326-
add_to_path "$config_file" "export PATH=$INSTALL_DIR:\$PATH"
327-
;;
328-
bash)
329-
add_to_path "$config_file" "export PATH=$INSTALL_DIR:\$PATH"
330-
;;
331-
ash)
332-
add_to_path "$config_file" "export PATH=$INSTALL_DIR:\$PATH"
333-
;;
334-
sh)
335-
add_to_path "$config_file" "export PATH=$INSTALL_DIR:\$PATH"
336-
;;
337-
*)
338-
export PATH=$INSTALL_DIR:$PATH
339-
print_message warning "Manually add the directory to $config_file (or similar):"
340-
print_message info " export PATH=$INSTALL_DIR:\$PATH"
341-
;;
342-
esac
343387
fi
344388

345389
if [ -n "${GITHUB_ACTIONS-}" ] && [ "${GITHUB_ACTIONS}" == "true" ]; then

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.