1
0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2026-01-26 01:57:26 +08:00

Compare commits

..

No commits in common. "06b0276675e978d80535259915fbb44011e10101" and "c686aa3dbb30704b2f8f52bf1aae19a7e41c23c1" have entirely different histories.

2 changed files with 79 additions and 55 deletions

2
.github/CODEOWNERS vendored
View File

@ -1,3 +1 @@
# Plugin owners
plugins/gitfast/ @felipec plugins/gitfast/ @felipec
plugins/sdk/ @rgoldberg

View File

@ -1,58 +1,84 @@
#!/usr/bin/env zsh
### SDKMAN Autocomplete for Oh My Zsh ### SDKMAN Autocomplete for Oh My Zsh
_sdk() { # This is the output from sdkman. All the these options are supported at the
case "${CURRENT}" in # moment.
2)
compadd -X $'Commands:\n' -- "${${(Mk)functions[@]:#__sdk_*}[@]#__sdk_}" # Usage: sdk <command> [candidate] [version]
compadd -n rm # sdk offline <enable|disable>
;; #
3) # commands:
case "${words[2]}" in # install or i <candidate> [version] [local-path]
l|ls|list|i|install) # uninstall or rm <candidate> <version>
compadd -X $'Candidates:\n' -- "${SDKMAN_CANDIDATES[@]}" # list or ls [candidate]
;; # use or u <candidate> <version>
ug|upgrade|h|home|c|current|u|use|d|default|rm|uninstall) # default or d <candidate> [version]
compadd -X $'Installed Candidates:\n' -- "${${(u)${(f)$(find -L -- "${SDKMAN_CANDIDATES_DIR}" -mindepth 2 -maxdepth 2 -type d)}[@]:h}[@]:t}" # current or c [candidate]
;; # upgrade or ug [candidate]
e|env) # version or v
compadd init # broadcast or b
;; # help or h
offline) # offline [enable|disable]
compadd enable disable # selfupdate [force]
;; # update
selfupdate) # flush <broadcast|archives|temp>
compadd force #
;; # candidate : the SDK to install: groovy, scala, grails, gradle, kotlin, etc.
flush) # use list command for comprehensive list of candidates
compadd archives broadcast temp version # eg: $ sdk list
;; # version : where optional, defaults to latest stable if not provided
esac # eg: $ sdk install groovy
;; # local-path : optional path to an existing local installation
4) # eg: $ sdk install groovy 2.4.13-local /opt/groovy-2.4.13
case "${words[2]}" in
i|install) local _sdk_commands=(
setopt localoptions kshglob install i
if [[ "${words[3]}" == 'java' ]]; then uninstall rm
compadd -X $'Installable Versions of java:\n' -- "${${${${${(f)$(__sdkman_list_versions "${words[3]}")}[@]:5:-4}[@]:#* | (local only|installed ) | *}[@]##* | | }[@]%%+( )}" list ls
else use u
compadd -X "Installable Versions of ${words[3]}:"$'\n' -- "${${(z)${(M)${(f)${$(__sdkman_list_versions "${words[3]}")//[*+>]+( )/-}}[@]:# *}[@]}[@]:#-*}" default d
fi current c
;; upgrade ug
h|home|u|use|d|default|rm|uninstall) version v
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}" broadcast b
;; help h
esac offline
;; selfupdate
5) update
case "${words[2]}" in flush
i|install) )
_files -X "Path to Local Installation of ${words[3]} ${words[4]}:"$'\n' -/
;; _listInstalledVersions() {
esac __sdkman_build_version_csv $1 | sed -e "s/,/ /g"
;; }
esac
_listInstallableVersions() {
# Remove local (+) and installed (*) versions from the list
__sdkman_list_versions $1 | sed -e '/^[^ ]/d;s/[+*] [^ ]\+//g;s/>//g'
}
_listAllVersion() {
# Remove (*), (+), and (>) characters from the list
__sdkman_list_versions $1 | sed -e '/^[^ ]/d;s/[*+>] //g'
}
_sdk () {
case $CURRENT in
2) compadd -- $_sdk_commands ;;
3) case "$words[2]" in
i|install|rm|uninstall|ls|list|u|use|d|default|c|current|ug|upgrade)
compadd -- $SDKMAN_CANDIDATES ;;
offline) compadd -- enable disable ;;
selfupdate) compadd -- force ;;
flush) compadd -- broadcast archives temp ;;
esac
;;
4) case "$words[2]" in
rm|uninstall|d|default) compadd -- $(_listInstalledVersions $words[3]) ;;
i|install) compadd -- $(_listInstallableVersions $words[3]) ;;
u|use) compadd -- $(_listAllVersion $words[3]) ;;
esac
;;
esac
} }
compdef _sdk sdk compdef _sdk sdk