-
Notifications
You must be signed in to change notification settings - Fork 0
/
dnvm
53 lines (51 loc) · 2.2 KB
/
dnvm
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
_dnvm_completions()
{
shopt -s nullglob
local cur prev dnvm_command semvers aliases upgrade dnvm_commands
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ $COMP_CWORD -gt 0 ]; then
dnvm_command="${COMP_WORDS[1]}"
fi
semvers=$(for dir in $HOME/.dnx/runtimes/*; do dirname=${dir##*/}; echo ${dirname#*.}; done)
aliases=$(for alias_file in $HOME/.dnx/alias/*; do file_name=${alias_file##*/}; echo ${file_name%.alias}; done)
upgrade="-f -force -u -unstable -r -runtime"
shopt -u nullglob
dnvm_commands="upgrade install use exec list alias unalias -h help -help --help update-self"
if [ ${prev} == dnvm ] ; then
COMPREPLY=( $(compgen -W "${opts} ${dnvm_commands}" -- ${cur}) )
return 0
elif [ ${dnvm_command} == use ] ; then
COMPREPLY=( $(compgen -W "$semvers $aliases" -- ${cur}) )
return 0
elif [ ${dnvm_command} == run ] ; then
COMPREPLY=( $(compgen -W "$semvers $aliases" -- ${cur}) )
return 0
elif [ ${dnvm_command} == exec ] ; then
COMPREPLY=( $(compgen -W "$semvers $aliases" -- ${cur}) )
return 0
elif [ ${dnvm_command} == upgrade ] ; then
COMPREPLY=( $(compgen -W "$upgrade" -- ${cur}) )
return 0
elif [ ${prev} == -r ] ; then
COMPREPLY=( $(compgen -W "mono coreclr" -- ${cur}) )
return 0
elif [ ${dnvm_command} == install ] && [ ${COMP_CWORD} == 2 ]; then
COMPREPLY=( $(compgen -W "$semvers $aliases latest *.nupkg" -- ${cur}) )
return 0
elif [ ${dnvm_command} == install ] && [ ${prev} == -arch ]; then
COMPREPLY=( $(compgen -W "arm x64 x86" -- ${cur}) )
return 0
elif [ ${dnvm_command} == install ] && [ ${COMP_CWORD} -gt 2 ]; then
COMPREPLY=( $(compgen -W "-a -alias -p -persistent -f -force -u -unstable -r -runtime -arch" -- ${cur}) )
return 0
elif [ ${dnvm_command} == alias ] && [ ${COMP_CWORD} == 3 ]; then
COMPREPLY=( $(compgen -W "$semvers $aliases *.nupkg" -- ${cur}) )
return 0
elif [ ${dnvm_command} == unalias ]; then
COMPREPLY=( $(compgen -W "$aliases" -- ${cur}) )
return 0
fi
}
complete -F _dnvm_completions dnvm