From 436dcfa11731bbef6f1f10222b497944cc8e3c4e Mon Sep 17 00:00:00 2001 From: Jauhien Piatlicki Date: Tue, 19 Aug 2014 13:26:12 +0200 Subject: add unset action --- src/modules/rust.eselect | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/src/modules/rust.eselect b/src/modules/rust.eselect index e334e9b..0734798 100644 --- a/src/modules/rust.eselect +++ b/src/modules/rust.eselect @@ -109,21 +109,9 @@ set_symlink() { fi } -# set the rust version - -set_version() { - local target=$1 - - if is_number "${target}"; then - local targets=( $(find_targets) ) - target=${targets[target-1]} - fi - - [[ -z ${target} || ! -x "${EROOT}/usr/bin/rustc-${target}" ]] \ - && die -q "Target \"$1\" doesn't appear to be valid!" - - local datadir="${EROOT}/usr/share/rust-${target}" +# unset the rust version +unset_version() { remove_symlink "${EROOT}"/usr/bin/rustc remove_symlink "${EROOT}"/usr/bin/rustdoc remove_symlink "${EROOT}/${SITELISP}"/rust-mode @@ -138,10 +126,28 @@ set_version() { remove_symlink "${EROOT}/${SITEVIM}/doc/rust.txt" remove_symlink "${EROOT}/${SITEZSH}/_rust" +} + +# set the rust version + +set_version() { + local target=$1 + + if is_number "${target}"; then + local targets=( $(find_targets) ) + target=${targets[target-1]} + fi + + [[ -z ${target} || ! -x "${EROOT}/usr/bin/rustc-${target}" ]] \ + && die -q "Target \"$1\" doesn't appear to be valid!" + + unset_version ln -s "${EROOT}/usr/bin/rustc-${target}" "${EROOT}/usr/bin/rustc" || die -q "rustc symlink setting failed" ln -s "${EROOT}/usr/bin/rustdoc-${target}" "${EROOT}/usr/bin/rustdoc" || die -q "rustdoc symlink setting failed" + local datadir="${EROOT}/usr/share/rust-${target}" + set_symlink "${datadir}/emacs/site-lisp/rust-mode" "${EROOT}/${SITELISP}/rust-mode" && \ set_symlink "${datadir}/emacs/site-lisp/site-gentoo.d/50rust-mode-gentoo.el" \ "${EROOT}/${SITELISP}/site-gentoo.d/50rust-mode-gentoo.el" && \ @@ -232,3 +238,15 @@ do_update() { local targets=( $(find_targets) ) do_set ${#targets[@]} } + +### unset action ### + +describe_unset() { + echo "Unset active rust version" +} + +do_unset() { + [[ $# -gt 0 ]] && die -q "Too many parameters" + + unset_version || die -q "Couldn't unset active version" +} -- cgit v1.2.3-65-gdbad