-
Notifications
You must be signed in to change notification settings - Fork 3
/
_gvm
76 lines (64 loc) · 1.52 KB
/
_gvm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#compdef gvm
#autoload
# gvm zsh completion, based on homebrew completion
local -a _1st_arguments
_1st_arguments=(
'install:install go versions'
'uninstall:uninstall go versions'
'cross:install go cross compilers'
'get:gets the latest code (for debugging)'
'list:list installed go versions'
'listall:list available versions'
'use:select a go version to use'
'diff:view changes to Go root'
'implode:completely remove gvm'
'linkthis:link this directory into $GOPATH'
'alias:manage go version aliases'
'pkgset:manage go packages sets'
'pkgenv:edit the environment for a package set'
'version:print the gvm version number'
)
local -a _alias
_alias=(
'create:create a new alias'
'delete:delete an alias'
'list:list aliases'
)
local -a _versions
_versions=(
$(
versions=( $(git ls-remote -t https://go.googlesource.com/go | awk -F/ '{ print $NF }' | xargs) )
for version in $versions; do
if [[ "$version" == go* ]]; then
echo $version
fi
if [[ "$version" == release* ]]; then
echo $version
fi
done
)
)
local -a _installed_versions
_installed_versions=(
$(
\ls ~/.gvm/gos 2>/dev/null
)
)
_arguments \
'*:: :->subcmds' && return 0
if (( CURRENT == 1 )); then
_describe -t commands "gvm subcommand" _1st_arguments
return
fi
if (( CURRENT == 2 )); then
case "$words[1]" in
alias)
_describe -t commands "gvm subcommand" _alias ;;
install)
_arguments "1: :( $_versions )" ;;
uninstall)
_arguments "1: :( $_installed_versions )" ;;
use)
_arguments "1: :( $_installed_versions )" ;;
esac
fi