1
0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2025-12-12 15:34:50 +08:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Ross Goldberg
06b0276675
sdk: support completion of new commands in 5.8.0 (#8870) 2020-04-30 20:28:07 +02:00
Marc Cornellà
58a1a1397e
meta: add Ross Goldberg as owner of the sdk plugin 2020-04-30 19:21:17 +02:00
Ross Goldberg
373e27d805
sdk: improve sdkman completion (#8854) 2020-04-30 18:46:17 +02:00
2 changed files with 55 additions and 79 deletions

2
.github/CODEOWNERS vendored
View File

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

View File

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