Parent directory

sdk.plugin.zsh

1579 bytes
 1#!/usr/bin/env zsh
 2
 3### SDKMAN Autocomplete for Oh My Zsh
 4
 5_sdk() {
 6	case "${CURRENT}" in
 7	2)
 8		compadd -X $'Commands:\n' -- "${${(Mk)functions[@]:#__sdk_*}[@]#__sdk_}"
 9		compadd -n rm
10		;;
11	3)
12		case "${words[2]}" in
13		l|ls|list|i|install)
14			compadd -X $'Candidates:\n' -- "${SDKMAN_CANDIDATES[@]}"
15			;;
16		ug|upgrade|h|home|c|current|u|use|d|default|rm|uninstall)
17			compadd -X $'Installed Candidates:\n' -- "${${(u)${(f)$(find -L -- "${SDKMAN_CANDIDATES_DIR}" -mindepth 2 -maxdepth 2 -type d)}[@]:h}[@]:t}"
18			;;
19		e|env)
20			compadd init
21			;;
22		offline)
23			compadd enable disable
24			;;
25		selfupdate)
26			compadd force
27			;;
28		flush)
29			compadd archives broadcast temp version
30			;;
31		esac
32		;;
33	4)
34		case "${words[2]}" in
35		i|install)
36			setopt localoptions kshglob
37			if [[ "${words[3]}" == 'java' ]]; then
38				compadd -X $'Installable Versions of java:\n' -- "${${${${${(f)$(__sdkman_list_versions "${words[3]}")}[@]:5:-4}[@]:#* | (local only|installed ) | *}[@]##* |            | }[@]%%+( )}"
39			else
40				compadd -X "Installable Versions of ${words[3]}:"$'\n' -- "${${(z)${(M)${(f)${$(__sdkman_list_versions "${words[3]}")//[*+>]+( )/-}}[@]:# *}[@]}[@]:#-*}"
41			fi
42			;;
43		h|home|u|use|d|default|rm|uninstall)
44			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}"
45			;;
46		esac
47		;;
48	5)
49		case "${words[2]}" in
50		i|install)
51			_files -X "Path to Local Installation of ${words[3]} ${words[4]}:"$'\n' -/
52			;;
53		esac
54		;;
55	esac
56}
57
58compdef _sdk sdk