Tweak ghcup upgrade

1. add --inplace flag
2. by default install into BIN_LOCATION
This commit is contained in:
Julian Ospald 2019-03-31 22:14:07 +08:00
parent ae99de5876
commit 36e8389bb0
No known key found for this signature in database
GPG Key ID: 511B62C09D50CD28
1 changed files with 10 additions and 3 deletions

13
ghcup
View File

@ -269,10 +269,12 @@ USAGE:
${SCRIPT} upgrade [FLAGS] [TARGET-LOCATION]
FLAGS:
-i, --inplace Update this script in-place (wherever it's at)
-h, --help Prints help information
ARGS:
[TARGET-LOCATION] Where to place the updated script (defaults to directory of the script).
[TARGET-LOCATION] Where to place the updated script (defaults to ${BIN_LOCATION}).
This is ignored if --inplace is issued as well.
")
exit 1
}
@ -1885,18 +1887,23 @@ while [ $# -gt 0 ] ; do
break;;
upgrade)
IN_PLACE=false
shift 1
while [ $# -gt 0 ] ; do
case $1 in
-h|--help) upgrade_usage;;
-i|--inplace) IN_PLACE=true
shift 1 ;;
*) TARGET_LOCATION=$1
break;;
esac
done
if [ -n "${TARGET_LOCATION}" ] ; then
if ${IN_PLACE} ; then
upgrade "$(dirname "$(posix_realpath "${SOURCE}")")"
elif [ -n "${TARGET_LOCATION}" ] ; then
upgrade "${TARGET_LOCATION}"
else
upgrade "$(dirname "$(posix_realpath "${SOURCE}")")"
upgrade "${BIN_LOCATION}"
fi
break;;
show)