Skip to content

Commit

Permalink
feat(install): Add version option to install script (#5728)
Browse files Browse the repository at this point in the history
feat(install): Add version option to install script
  • Loading branch information
luismgsantos committed Mar 3, 2024
1 parent ae711c0 commit f66bfd9
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions install/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ usage() {
"-b, --bin-dir" "Override the bin installation directory [default: ${BIN_DIR}]" \
"-a, --arch" "Override the architecture identified by the installer [default: ${ARCH}]" \
"-B, --base-url" "Override the base URL used for downloading releases [default: ${BASE_URL}]" \
"-v, --version" "Install a specific version of starship [default: ${VERSION}]" \
"-h, --help" "Display this help message"
}

Expand Down Expand Up @@ -424,6 +425,10 @@ if [ -z "${BASE_URL-}" ]; then
BASE_URL="https://github.com/starship/starship/releases"
fi

if [ -z "${VERSION-}" ]; then
VERSION="latest"
fi

# Non-POSIX shells can break once executing code due to semantic differences
verify_shell_is_posix_or_exit

Expand All @@ -446,6 +451,10 @@ while [ "$#" -gt 0 ]; do
BASE_URL="$2"
shift 2
;;
-v | --version)
VERSION="$2"
shift 2
;;

-V | --verbose)
VERBOSE=1
Expand Down Expand Up @@ -476,6 +485,10 @@ while [ "$#" -gt 0 ]; do
BASE_URL="${1#*=}"
shift 1
;;
-v=* | --version=*)
VERSION="${1#*=}"
shift 1
;;
-V=* | --verbose=*)
VERBOSE="${1#*=}"
shift 1
Expand Down Expand Up @@ -517,13 +530,18 @@ if [ "${PLATFORM}" = "pc-windows-msvc" ]; then
EXT=zip
fi

URL="${BASE_URL}/latest/download/starship-${TARGET}.${EXT}"
if [ "${VERSION}" != "latest" ]; then
URL="${BASE_URL}/download/${VERSION}/starship-${TARGET}.${EXT}"
else
URL="${BASE_URL}/latest/download/starship-${TARGET}.${EXT}"
fi

info "Tarball URL: ${UNDERLINE}${BLUE}${URL}${NO_COLOR}"
confirm "Install Starship ${GREEN}latest${NO_COLOR} to ${BOLD}${GREEN}${BIN_DIR}${NO_COLOR}?"
confirm "Install Starship ${GREEN}${VERSION}${NO_COLOR} to ${BOLD}${GREEN}${BIN_DIR}${NO_COLOR}?"
check_bin_dir "${BIN_DIR}"

install "${EXT}"
completed "Starship installed"
completed "Starship ${VERSION} installed"

printf '\n'
info "Please follow the steps for your shell to complete the installation:"
Expand Down

0 comments on commit f66bfd9

Please sign in to comment.