b054e25d25aacdde7c64b002147b6cebdd78d0d2

Author
Rahul Somasunderam <rahul.som@gmail.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

Add plugin for SDKMAN (#6483)

SDKMAN! is a tool for managing parallel versions of multiple
Software Development Kits on most Unix based systems.

Diff

  1diff --git a/plugins/sdk/README.md b/plugins/sdk/README.md
  2new file mode 100644
  3index 0000000000000000000000000000000000000000..b237f3b4c43254ba31546ae73c7d6aa26964e2d2
  4--- /dev/null
  5+++ b/plugins/sdk/README.md
  6@@ -0,0 +1,8 @@
  7+# sdk
  8+
  9+Plugin for SDKMAN, a tool for managing parallel versions of multiple Software Development Kits on most Unix based systems.
 10+Provides autocompletion for all known commands.
 11+
 12+## Requirements
 13+
 14+ * [SDKMAN](http://sdkman.io/)
 15diff --git a/plugins/sdk/sdk.plugin.zsh b/plugins/sdk/sdk.plugin.zsh
 16new file mode 100644
 17index 0000000000000000000000000000000000000000..d00459b16850e2120028e0e105f7b56d46b0ebc4
 18--- /dev/null
 19+++ b/plugins/sdk/sdk.plugin.zsh
 20@@ -0,0 +1,82 @@
 21+### SDKMAN Autocomplete for Oh My Zsh
 22+
 23+# This is the output from sdkman. All the these options are supported at the
 24+# moment.
 25+
 26+# Usage: sdk <command> [candidate] [version]
 27+#        sdk offline <enable|disable>
 28+#
 29+#    commands:
 30+#        install   or i    <candidate> [version]
 31+#        uninstall or rm   <candidate> <version>
 32+#        list      or ls   [candidate]
 33+#        use       or u    <candidate> [version]
 34+#        default   or d    <candidate> [version]
 35+#        current   or c    [candidate]
 36+#        upgrade   or ug   [candidate]
 37+#        version   or v
 38+#        broadcast or b
 39+#        help      or h
 40+#        offline           [enable|disable]
 41+#        selfupdate        [force]
 42+#        update
 43+#        flush             <candidates|broadcast|archives|temp>
 44+#
 45+#    candidate  :  the SDK to install: groovy, scala, grails, gradle, kotlin, etc.
 46+#                  use list command for comprehensive list of candidates
 47+#                  eg: $ sdk list
 48+#
 49+#    version    :  where optional, defaults to latest stable if not provided
 50+#                  eg: $ sdk install groovy
 51+
 52+local _sdk_commands=(
 53+    install     i
 54+    uninstall   rm
 55+    list        ls
 56+    use         u
 57+    default     d
 58+    current     c
 59+    upgrade     ug
 60+    version     v
 61+    broadcast   b
 62+    help        h
 63+    offline
 64+    selfupdate
 65+    update
 66+    flush
 67+)
 68+
 69+_listInstalledVersions() {
 70+  __sdkman_build_version_csv $1 | sed -e "s/,/ /g"
 71+}
 72+
 73+_listInstallableVersions() {
 74+  __sdkman_list_versions $1 | grep "^ " | sed -e "s/\* /*/g" | \
 75+      sed -e "s/>//g" | xargs -n 1 echo | grep -v "^*"
 76+}
 77+
 78+_listAllVersion() {
 79+  __sdkman_list_versions $1 | grep "^ " | sed -e "s/\*/ /g" | sed -e "s/>//g"
 80+}
 81+
 82+_sdk () {
 83+  case $CURRENT in
 84+    2)  compadd -- $_sdk_commands ;;
 85+    3)  case "$words[2]" in
 86+          i|install|rm|uninstall|ls|list|u|use|d|default|c|current|ug|upgrade)
 87+                      compadd -- $SDKMAN_CANDIDATES ;;
 88+          offline)    compadd -- enable disable ;;
 89+          selfupdate) compadd -- force ;;
 90+          flush)      compadd -- candidates broadcast archives temp ;;
 91+        esac
 92+        ;;
 93+    4)  case "$words[2]" in
 94+          rm|uninstall|d|default) compadd -- $(_listInstalledVersions $words[3]) ;;
 95+          i|install)              compadd -- $(_listInstallableVersions $words[3]) ;;
 96+          u|use)                  compadd -- $(_listAllVersion $words[3]) ;;
 97+        esac
 98+        ;;
 99+  esac
100+}
101+
102+compdef _sdk sdk