Add rm subcommand
This commit is contained in:
parent
347df231c5
commit
561173b40b
52
ghcup
52
ghcup
@ -59,6 +59,7 @@ SUBCOMMANDS:
|
|||||||
show Show current/installed GHC
|
show Show current/installed GHC
|
||||||
set Set currently active GHC version
|
set Set currently active GHC version
|
||||||
self-update Update this script in-place
|
self-update Update this script in-place
|
||||||
|
rm Remove an already installed GHC
|
||||||
|
|
||||||
DISCUSSION:
|
DISCUSSION:
|
||||||
ghcup installs the Glasgow Haskell Compiler from the official
|
ghcup installs the Glasgow Haskell Compiler from the official
|
||||||
@ -143,6 +144,22 @@ FLAGS:
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rm_usage() {
|
||||||
|
(>&2 echo "ghcup-rm
|
||||||
|
Remove the given GHC version installed by ghcup
|
||||||
|
|
||||||
|
USAGE:
|
||||||
|
${SCRIPT} rm [FLAGS] <VERSION>
|
||||||
|
|
||||||
|
FLAGS:
|
||||||
|
-h, --help Prints help information
|
||||||
|
|
||||||
|
ARGS:
|
||||||
|
<VERSION> E.g. \"8.4.3\" or \"8.6.1\"
|
||||||
|
")
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
## utilities ##
|
## utilities ##
|
||||||
|
|
||||||
@ -474,6 +491,29 @@ show_ghc_installed() {
|
|||||||
unset real_ghc
|
unset real_ghc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
## rm subcommand ##
|
||||||
|
|
||||||
|
rm_ghc() {
|
||||||
|
myghcver=$1
|
||||||
|
inst_location=$(get_ghc_location "${myghcver}")
|
||||||
|
|
||||||
|
[ -z "${myghcver}" ] && die "We are paranoid, ghcver not set"
|
||||||
|
|
||||||
|
if ghc_already_installed "${myghcver}" ; then
|
||||||
|
for f in "${BIN_LOCATION}"/*-"${myghcver}" ; do
|
||||||
|
# https://tanguy.ortolo.eu/blog/article113/test-symlink
|
||||||
|
[ ! -e "${f}" ] && [ ! -h "${f}" ] && die "Something went wrong, ${f} does not exist!"
|
||||||
|
edo rm "${f}"
|
||||||
|
done
|
||||||
|
edo rm -r "${inst_location}"
|
||||||
|
else
|
||||||
|
warning_message "${myghcver} doesn't appear to be installed, skipping"
|
||||||
|
fi
|
||||||
|
|
||||||
|
unset myghcver inst_location f
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## command line parsing and entry point ##
|
## command line parsing and entry point ##
|
||||||
|
|
||||||
@ -553,6 +593,18 @@ while [ $# -gt 0 ] ; do
|
|||||||
show_ghc
|
show_ghc
|
||||||
fi
|
fi
|
||||||
break;;
|
break;;
|
||||||
|
rm)
|
||||||
|
shift 1
|
||||||
|
while [ $# -gt 0 ] ; do
|
||||||
|
case $1 in
|
||||||
|
-h|--help) rm_usage;;
|
||||||
|
*) GHC_VER=$1
|
||||||
|
break;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
[ "${GHC_VER}" ] || rm_usage
|
||||||
|
rm_ghc "${GHC_VER}"
|
||||||
|
break;;
|
||||||
*) usage;;
|
*) usage;;
|
||||||
esac
|
esac
|
||||||
break;;
|
break;;
|
||||||
|
Loading…
Reference in New Issue
Block a user