2016-02-29 00:53:43 -07:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
_asdf () {
|
|
|
|
local cur=${COMP_WORDS[COMP_CWORD]}
|
|
|
|
local cmd=${COMP_WORDS[1]}
|
|
|
|
local prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
|
|
local plugins=$(asdf plugin-list | tr '\n' ' ')
|
|
|
|
|
|
|
|
COMPREPLY=()
|
|
|
|
|
|
|
|
case "$cmd" in
|
|
|
|
plugin-update)
|
|
|
|
COMPREPLY=($(compgen -W "$plugins --all" -- $cur))
|
|
|
|
;;
|
2016-07-24 08:47:17 -07:00
|
|
|
plugin-remove|current|list|list-all)
|
2016-02-29 00:53:43 -07:00
|
|
|
COMPREPLY=($(compgen -W "$plugins" -- $cur))
|
|
|
|
;;
|
|
|
|
install)
|
|
|
|
if [[ "$plugins" == *"$prev"* ]] ; then
|
|
|
|
local versions=$(asdf list-all $prev)
|
|
|
|
COMPREPLY=($(compgen -W "$versions" -- $cur))
|
|
|
|
else
|
|
|
|
COMPREPLY=($(compgen -W "$plugins" -- $cur))
|
|
|
|
fi
|
|
|
|
;;
|
2017-04-25 05:22:40 -07:00
|
|
|
uninstall|where|reshim|local|global)
|
2016-02-29 00:53:43 -07:00
|
|
|
if [[ "$plugins" == *"$prev"* ]] ; then
|
|
|
|
local versions=$(asdf list $prev)
|
|
|
|
COMPREPLY=($(compgen -W "$versions" -- $cur))
|
|
|
|
else
|
|
|
|
COMPREPLY=($(compgen -W "$plugins" -- $cur))
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
2017-04-25 05:22:40 -07:00
|
|
|
local cmds='plugin-add plugin-list plugin-remove plugin-update install uninstall update current where list list-all local global reshim'
|
2016-02-29 00:53:43 -07:00
|
|
|
COMPREPLY=($(compgen -W "$cmds" -- $cur))
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
complete -F _asdf asdf
|