373e27d805ad22a0c6e903e418590fb965de7181
- Author
- Ross Goldberg <rgoldberg@users.noreply.github.com>
- Committer
- GitHub <noreply@github.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/plugins/sdk/sdk.plugin.zsh b/plugins/sdk/sdk.plugin.zsh
2index e49caaf2f9c74692b2fbb76c6c6c02395b22dd73..a1069fea4b1e5badb580cf5d9343e4f8062c5783 100644
3--- a/plugins/sdk/sdk.plugin.zsh
4+++ b/plugins/sdk/sdk.plugin.zsh
5@@ -1,84 +1,55 @@
6-### SDKMAN Autocomplete for Oh My Zsh
7-
8-# This is the output from sdkman. All the these options are supported at the
9-# moment.
10-
11-# Usage: sdk <command> [candidate] [version]
12-# sdk offline <enable|disable>
13-#
14-# commands:
15-# install or i <candidate> [version] [local-path]
16-# uninstall or rm <candidate> <version>
17-# list or ls [candidate]
18-# use or u <candidate> <version>
19-# default or d <candidate> [version]
20-# current or c [candidate]
21-# upgrade or ug [candidate]
22-# version or v
23-# broadcast or b
24-# help or h
25-# offline [enable|disable]
26-# selfupdate [force]
27-# update
28-# flush <broadcast|archives|temp>
29-#
30-# candidate : the SDK to install: groovy, scala, grails, gradle, kotlin, etc.
31-# use list command for comprehensive list of candidates
32-# eg: $ sdk list
33-# version : where optional, defaults to latest stable if not provided
34-# eg: $ sdk install groovy
35-# local-path : optional path to an existing local installation
36-# eg: $ sdk install groovy 2.4.13-local /opt/groovy-2.4.13
37-
38-local _sdk_commands=(
39- install i
40- uninstall rm
41- list ls
42- use u
43- default d
44- current c
45- upgrade ug
46- version v
47- broadcast b
48- help h
49- offline
50- selfupdate
51- update
52- flush
53-)
54-
55-_listInstalledVersions() {
56- __sdkman_build_version_csv $1 | sed -e "s/,/ /g"
57-}
58-
59-_listInstallableVersions() {
60- # Remove local (+) and installed (*) versions from the list
61- __sdkman_list_versions $1 | sed -e '/^[^ ]/d;s/[+*] [^ ]\+//g;s/>//g'
62-}
63+#!/usr/bin/env zsh
64
65-_listAllVersion() {
66- # Remove (*), (+), and (>) characters from the list
67- __sdkman_list_versions $1 | sed -e '/^[^ ]/d;s/[*+>] //g'
68-}
69+### SDKMAN Autocomplete for Oh My Zsh
70
71-_sdk () {
72- case $CURRENT in
73- 2) compadd -- $_sdk_commands ;;
74- 3) case "$words[2]" in
75- i|install|rm|uninstall|ls|list|u|use|d|default|c|current|ug|upgrade)
76- compadd -- $SDKMAN_CANDIDATES ;;
77- offline) compadd -- enable disable ;;
78- selfupdate) compadd -- force ;;
79- flush) compadd -- broadcast archives temp ;;
80- esac
81- ;;
82- 4) case "$words[2]" in
83- rm|uninstall|d|default) compadd -- $(_listInstalledVersions $words[3]) ;;
84- i|install) compadd -- $(_listInstallableVersions $words[3]) ;;
85- u|use) compadd -- $(_listAllVersion $words[3]) ;;
86- esac
87- ;;
88- esac
89+_sdk() {
90+ case "${CURRENT}" in
91+ 2)
92+ compadd -X $'Commands:\n' -- "${${(Mk)functions[@]:#__sdk_*}[@]#__sdk_}"
93+ compadd -n rm
94+ ;;
95+ 3)
96+ case "${words[2]}" in
97+ l|ls|list|i|install)
98+ compadd -X $'Candidates:\n' -- "${SDKMAN_CANDIDATES[@]}"
99+ ;;
100+ ug|upgrade|c|current|u|use|d|default|rm|uninstall)
101+ compadd -X $'Installed Candidates:\n' -- "${${(u)${(f)$(find -L -- "${SDKMAN_CANDIDATES_DIR}" -mindepth 2 -maxdepth 2 -type d)}[@]:h}[@]:t}"
102+ ;;
103+ offline)
104+ compadd enable disable