Enhancements for remove-go

- add completion for remove-go
- remove-go can now handle the "tip" version
This commit is contained in:
Thomas Goldbrunner 2017-07-27 12:53:49 +02:00
parent 826bd61fb8
commit dddc7bfedb
No known key found for this signature in database
GPG Key ID: 3D1E9133640DA4FB
2 changed files with 25 additions and 2 deletions

View File

@ -11,7 +11,7 @@ Provides following functions/aliases:
If called without argument, the 'stable' version will be loaded.
- ```remove-go```: Remove the go version specified by the first argument from
~/.gimme/*
- Completions for ```gimme``` and ```load-go```
- Completions for ```gimme```, ```load-go``` and ```remove-go```
```gimme``` is assumed to be in ```~/bin```, so make
sure to add this folder to the $PATH variable.

View File

@ -39,7 +39,16 @@ remove-go() {
echo "Usage: remove-go GO_VERSION"
return 0
else
if [ "$1" = "stable" ] ; then
if [ "$1" = "tip" ] ; then
if ! [ -e ~/.gimme/versions/go ] ; then
echo "go version tip is not installed"
return 0
fi
rm -rf ~/.gimme/versions/go || return 1
rm ~/.gimme/envs/gotip.env || return 1
rm ~/.gimme/envs/go.git.* || return 1
return 0
elif [ "$1" = "stable" ] ; then
if ! [ -e ~/.gimme/versions/stable ] ; then
echo "go version stable is not installed"
return 0
@ -116,5 +125,19 @@ __load-go_completion() {
_values 'go_versions' ${go_versions[@]}
}
__remove-go_completion() {
local context state state_descr line
typeset -a installed_versions
if [ "$(ls ~/.gimme/versions | grep stable)" ] ; then
installed_versions+=('stable')
fi
if [ -d ~/.gimme/versions/go ] ; then
installed_versions+=('tip')
fi
installed_versions+=($(ls ~/.gimme/versions | egrep -oZ '[0-9].[0-9].[0-9]'))
_values -w 'installed_versions' ${installed_versions[@]}
}
compdef __gimme_completion gimme
compdef __load-go_completion load-go
compdef __remove-go_completion remove-go