1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-06-07 11:00:47 +00:00

feat(install): Add help argument to install.sh (#2729)

This commit is contained in:
Thomas O'Donnell 2021-05-18 16:01:02 +02:00 committed by GitHub
parent 21f4dc3e74
commit fb02a4523b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 20 deletions

View File

@ -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. 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 #### Install via Package Manager
##### Example: [Homebrew](https://brew.sh/): ##### Example: [Homebrew](https://brew.sh/):

View File

@ -2,26 +2,6 @@
# shellcheck disable=SC2039 # 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 set -eu
printf '\n' printf '\n'
@ -138,6 +118,39 @@ unpack() {
return 1 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() { elevate_priv() {
if ! has sudo; then if ! has sudo; then
error 'Could not find the command "sudo", needed to get permissions for install.' error 'Could not find the command "sudo", needed to get permissions for install.'
@ -205,6 +218,8 @@ detect_platform() {
# Currently supporting: # Currently supporting:
# - x86_64 # - x86_64
# - i386 # - i386
# - arm
# - arm64
detect_arch() { detect_arch() {
local arch local arch
arch="$(uname -m | tr '[:upper:]' '[:lower:]')" arch="$(uname -m | tr '[:upper:]' '[:lower:]')"
@ -262,6 +277,7 @@ check_bin_dir() {
if [ ! -d "$BIN_DIR" ]; then if [ ! -d "$BIN_DIR" ]; then
error "Installation location $BIN_DIR does not appear to be a directory" 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." info "Make sure the location exists and is a directory, then try again."
usage
exit 1 exit 1
fi fi
@ -355,6 +371,10 @@ while [ "$#" -gt 0 ]; do
FORCE=1 FORCE=1
shift 1 shift 1
;; ;;
-h | --help)
usage
exit
;;
-p=* | --platform=*) -p=* | --platform=*)
PLATFORM="${1#*=}" PLATFORM="${1#*=}"
@ -383,6 +403,7 @@ while [ "$#" -gt 0 ]; do
*) *)
error "Unknown option: $1" error "Unknown option: $1"
usage
exit 1 exit 1
;; ;;
esac esac