diff options
author | Thomas O'Donnell <andytom@users.noreply.github.com> | 2021-05-18 16:01:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-18 10:01:02 -0400 |
commit | fb02a4523bf1348d9eac71738114c87a7457af6b (patch) | |
tree | 2eda66d547f88e18ad9a845bea75eb640c7f6c53 | |
parent | 21f4dc3e748d3424137b9a1fbc0307c8a6cbd6a8 (diff) |
feat(install): Add help argument to install.sh (#2729)
-rw-r--r-- | README.md | 7 | ||||
-rwxr-xr-x | install/install.sh | 61 |
2 files changed, 48 insertions, 20 deletions
@@ -161,6 +161,13 @@ shown below. Can't see yours? Have a look at the [extra platform instructions](h ``` To update the Starship itself, rerun the above script. It will replace the current version without touching Starship's configuration. + + **Note** - The defaults of the install script can be overridden see the built-in help. + + ```sh + sh -c "$(curl -fsSL https://starship.rs/install.sh)" -- --help + ``` + #### Install via Package Manager ##### Example: [Homebrew](https://brew.sh/): diff --git a/install/install.sh b/install/install.sh index b08474b43..6e1c41ab1 100755 --- a/install/install.sh +++ b/install/install.sh @@ -2,26 +2,6 @@ # shellcheck disable=SC2039 -# Options -# -# -V, --verbose -# Enable verbose output for the installer -# -# -f, -y, --force, --yes -# Skip the confirmation prompt during installation -# -# -p, --platform -# Override the platform identified by the installer -# -# -b, --bin-dir -# Override the bin installation directory -# -# -a, --arch -# Override the architecture identified by the installer -# -# -B, --base-url -# Override the base URL used for downloading releases - set -eu printf '\n' @@ -138,6 +118,39 @@ unpack() { return 1 } +usage() { + cat <<EOT +install.sh [option] + +Fetch and install the latest version of starship, if starship is already +installed it will be updated to the latest version. + +Options + + -V, --verbose + Enable verbose output for the installer + + -f, -y, --force, --yes + Skip the confirmation prompt during installation + + -p, --platform + Override the platform identified by the installer [default: ${PLATFORM}] + + -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}] + + -h, --help + Dispays this help message + +EOT +} + elevate_priv() { if ! has sudo; then error 'Could not find the command "sudo", needed to get permissions for install.' @@ -205,6 +218,8 @@ detect_platform() { # Currently supporting: # - x86_64 # - i386 +# - arm +# - arm64 detect_arch() { local arch arch="$(uname -m | tr '[:upper:]' '[:lower:]')" @@ -262,6 +277,7 @@ check_bin_dir() { if [ ! -d "$BIN_DIR" ]; then error "Installation location $BIN_DIR does not appear to be a directory" info "Make sure the location exists and is a directory, then try again." + usage exit 1 fi @@ -355,6 +371,10 @@ while [ "$#" -gt 0 ]; do FORCE=1 shift 1 ;; + -h | --help) + usage + exit + ;; -p=* | --platform=*) PLATFORM="${1#*=}" @@ -383,6 +403,7 @@ while [ "$#" -gt 0 ]; do *) error "Unknown option: $1" + usage exit 1 ;; esac |