Rename self-update to upgrade, fixes #38

This commit is contained in:
Julian Ospald 2018-11-04 16:53:49 +08:00
parent 2ef3c22cab
commit 475d060abe
No known key found for this signature in database
GPG Key ID: 511B62C09D50CD28
2 changed files with 19 additions and 19 deletions

View File

@ -62,4 +62,4 @@ edo ghcup -v list -t cabal-install
edo ghc --version
# self update destructively
edo ghcup -v self-update
edo ghcup -v upgrade

36
ghcup
View File

@ -180,7 +180,7 @@ SUBCOMMANDS:
show Show current/installed GHC
set Set currently active GHC version
list Show available GHCs and other tools (upstream)
self-update Update this script in-place
upgrade Upgrade this script in-place
rm Remove an already installed GHC
install-cabal Install cabal-install
debug-info Print debug info (e.g. detected system/distro)
@ -245,16 +245,16 @@ DISCUSSION:
exit 1
}
# @FUNCTION: self_update_usage
# @FUNCTION: upgrade_usage
# @DESCRIPTION:
# Print the help message for 'ghcup self-update' to STDERR
# Print the help message for 'ghcup upgrade' to STDERR
# and exit the script with status code 1.
self_update_usage() {
(>&2 echo "ghcup-self-update
upgrade_usage() {
(>&2 echo "ghcup-upgrade
Update the ghcup script in-place
USAGE:
${SCRIPT} self-update [FLAGS] [TARGET-LOCATION]
${SCRIPT} upgrade [FLAGS] [TARGET-LOCATION]
FLAGS:
-h, --help Prints help information
@ -657,7 +657,7 @@ check_meta_file_version() {
}" "$1")
if [ "${mymetavar}" != "$2" ] ; then
die "Unsupported meta file format, run: ghcup self-update"
die "Unsupported meta file format, run: ${SCRIPT} upgrade"
fi
unset mymetavar
@ -1035,7 +1035,7 @@ install_ghc() {
warning_message "Consider running: ghcup rm ${myghcver}"
fi
die "Failed to install, consider updating this script via: ${SCRIPT} self-update"
die "Failed to install, consider updating this script via: ${SCRIPT} upgrade"
}
for f in "${inst_location}"/bin/*-"${myghcver}" ; do
@ -1092,17 +1092,17 @@ set_ghc() {
################################
#--[ Subcommand self-update ]--#
################################
############################
#--[ Subcommand upgrade ]--#
############################
# @FUNCTION: self_update
# @FUNCTION: upgrade
# @USAGE: <install-location>
# @DESCRIPTION:
# Downloads the latest version of this script and places it into
# the given directory.
self_update() {
upgrade() {
target_location=$1
[ -e "${target_location}" ] || die "Destination \"${target_location}\" does not exist, cannot update script"
@ -1380,7 +1380,7 @@ compile_ghc() {
[ -e "${tmp_dir}/${download_tarball_name}" ] && rm "${tmp_dir}/${download_tarball_name}"
[ -e "${tmp_dir}/ghc-${myghcver}" ] && rm -r "${tmp_dir}/ghc-${myghcver}"
die "Failed to install, consider updating this script via:
${SCRIPT} self-update
${SCRIPT} upgrade
Also check https://ghc.haskell.org/trac/ghc/wiki/Building/Preparation/Linux for build requirements and follow the instructions."
}
@ -1571,19 +1571,19 @@ if ! is_sourced ; then
[ "${GHC_VER}" ] || set_usage
set_ghc "${GHC_VER}"
break;;
self-update)
upgrade)
shift 1
while [ $# -gt 0 ] ; do
case $1 in
-h|--help) self_update_usage;;
-h|--help) upgrade_usage;;
*) TARGET_LOCATION=$1
break;;
esac
done
if [ "${TARGET_LOCATION}" ] ; then
self_update "${TARGET_LOCATION}"
upgrade "${TARGET_LOCATION}"
else
self_update "$(dirname "$(posix_realpath "${SOURCE}")")"
upgrade "$(dirname "$(posix_realpath "${SOURCE}")")"
fi
break;;
show)