2020-04-30 18:46:17 +02:00
|
|
|
#!/usr/bin/env zsh
|
2019-05-08 10:27:05 +02:00
|
|
|
|
2020-04-30 18:46:17 +02:00
|
|
|
### SDKMAN Autocomplete for Oh My Zsh
|
2019-05-08 10:27:05 +02:00
|
|
|
|
2020-04-30 18:46:17 +02:00
|
|
|
_sdk() {
|
|
|
|
case "${CURRENT}" in
|
|
|
|
2)
|
|
|
|
compadd -X $'Commands:\n' -- "${${(Mk)functions[@]:#__sdk_*}[@]#__sdk_}"
|
|
|
|
compadd -n rm
|
|
|
|
;;
|
|
|
|
3)
|
|
|
|
case "${words[2]}" in
|
|
|
|
l|ls|list|i|install)
|
|
|
|
compadd -X $'Candidates:\n' -- "${SDKMAN_CANDIDATES[@]}"
|
|
|
|
;;
|
|
|
|
ug|upgrade|c|current|u|use|d|default|rm|uninstall)
|
|
|
|
compadd -X $'Installed Candidates:\n' -- "${${(u)${(f)$(find -L -- "${SDKMAN_CANDIDATES_DIR}" -mindepth 2 -maxdepth 2 -type d)}[@]:h}[@]:t}"
|
|
|
|
;;
|
|
|
|
offline)
|
|
|
|
compadd enable disable
|
|
|
|
;;
|
|
|
|
selfupdate)
|
|
|
|
compadd force
|
|
|
|
;;
|
|
|
|
flush)
|
|
|
|
compadd archives broadcast temp version
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
4)
|
|
|
|
case "${words[2]}" in
|
|
|
|
i|install)
|
|
|
|
setopt localoptions kshglob
|
|
|
|
if [[ "${words[3]}" == 'java' ]]; then
|
|
|
|
compadd -X $'Installable Versions of java:\n' -- "${${${${${(f)$(__sdkman_list_versions "${words[3]}")}[@]:5:-4}[@]:#* | (local only|installed ) | *}[@]##* | | }[@]%%+( )}"
|
|
|
|
else
|
|
|
|
compadd -X "Installable Versions of ${words[3]}:"$'\n' -- "${${(z)${(M)${(f)${$(__sdkman_list_versions "${words[3]}")//[*+>]+( )/-}}[@]:# *}[@]}[@]:#-*}"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
u|use|d|default|rm|uninstall)
|
|
|
|
compadd -X "Installed Versions of ${words[3]}:"$'\n' -- "${${(f)$(find -L -- "${SDKMAN_CANDIDATES_DIR}/${words[3]}" -mindepth 1 -maxdepth 1 -type d -not -name 'current')}[@]:t}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
5)
|
|
|
|
case "${words[2]}" in
|
|
|
|
i|install)
|
|
|
|
_files -X "Path to Local Installation of ${words[3]} ${words[4]}:"$'\n' -/
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
esac
|
2019-05-08 10:27:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
compdef _sdk sdk
|