sdk.plugin.zsh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. ### SDKMAN Autocomplete for Oh My Zsh
  2. # This is the output from sdkman. All the these options are supported at the
  3. # moment.
  4. # Usage: sdk <command> [candidate] [version]
  5. # sdk offline <enable|disable>
  6. #
  7. # commands:
  8. # install or i <candidate> [version] [local-path]
  9. # uninstall or rm <candidate> <version>
  10. # list or ls [candidate]
  11. # use or u <candidate> <version>
  12. # default or d <candidate> [version]
  13. # current or c [candidate]
  14. # upgrade or ug [candidate]
  15. # version or v
  16. # broadcast or b
  17. # help or h
  18. # offline [enable|disable]
  19. # selfupdate [force]
  20. # update
  21. # flush <broadcast|archives|temp>
  22. #
  23. # candidate : the SDK to install: groovy, scala, grails, gradle, kotlin, etc.
  24. # use list command for comprehensive list of candidates
  25. # eg: $ sdk list
  26. # version : where optional, defaults to latest stable if not provided
  27. # eg: $ sdk install groovy
  28. # local-path : optional path to an existing local installation
  29. # eg: $ sdk install groovy 2.4.13-local /opt/groovy-2.4.13
  30. local _sdk_commands=(
  31. install i
  32. uninstall rm
  33. list ls
  34. use u
  35. default d
  36. current c
  37. upgrade ug
  38. version v
  39. broadcast b
  40. help h
  41. offline
  42. selfupdate
  43. update
  44. flush
  45. )
  46. _listInstalledVersions() {
  47. __sdkman_build_version_csv $1 | sed -e "s/,/ /g"
  48. }
  49. _listInstallableVersions() {
  50. # Remove local (+) and installed (*) versions from the list
  51. __sdkman_list_versions $1 | sed -e '/^[^ ]/d;s/[+*] [^ ]\+//g;s/>//g'
  52. }
  53. _listAllVersion() {
  54. # Remove (*), (+), and (>) characters from the list
  55. __sdkman_list_versions $1 | sed -e '/^[^ ]/d;s/[*+>] //g'
  56. }
  57. _sdk () {
  58. case $CURRENT in
  59. 2) compadd -- $_sdk_commands ;;
  60. 3) case "$words[2]" in
  61. i|install|rm|uninstall|ls|list|u|use|d|default|c|current|ug|upgrade)
  62. compadd -- $SDKMAN_CANDIDATES ;;
  63. offline) compadd -- enable disable ;;
  64. selfupdate) compadd -- force ;;
  65. flush) compadd -- broadcast archives temp ;;
  66. esac
  67. ;;
  68. 4) case "$words[2]" in
  69. rm|uninstall|d|default) compadd -- $(_listInstalledVersions $words[3]) ;;
  70. i|install) compadd -- $(_listInstallableVersions $words[3]) ;;
  71. u|use) compadd -- $(_listAllVersion $words[3]) ;;
  72. esac
  73. ;;
  74. esac
  75. }
  76. compdef _sdk sdk