From 5ca2c43aed76f5ab061bc6cdec6cad65ae5593f9 Mon Sep 17 00:00:00 2001 From: Marcos Pereira Date: Mon, 4 Jan 2021 18:18:13 -0500 Subject: [PATCH] Add support to newer versions of sdkman Some new commands are available, and also aliases for commands such as `i` for `install`. --- completion/available/sdkman.completion.bash | 39 +++++++++++---------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/completion/available/sdkman.completion.bash b/completion/available/sdkman.completion.bash index b4d62da115..ce4b3673b9 100644 --- a/completion/available/sdkman.completion.bash +++ b/completion/available/sdkman.completion.bash @@ -6,33 +6,36 @@ _sdkman_complete() COMPREPLY=() if [ $COMP_CWORD -eq 1 ]; then - COMPREPLY=( $(compgen -W "install uninstall rm list ls use current outdated version default selfupdate broadcast offline help flush" -- ${COMP_WORDS[COMP_CWORD]}) ) + COMPREPLY=( $(compgen -W "install uninstall rm list ls use default home env current upgrade ug version broadcast help offline selfupdate update flush" -- ${COMP_WORDS[COMP_CWORD]}) ) elif [ $COMP_CWORD -eq 2 ]; then case "${COMP_WORDS[COMP_CWORD-1]}" in - "install" | "uninstall" | "rm" | "list" | "ls" | "use" | "current" | "outdated" ) + "install" | "i" | "uninstall" | "rm" | "list" | "ls" | "use" | "u" | "default" | "d" | "home" | "h" | "current" | "c" | "upgrade" | "ug" ) CANDIDATES=$(echo "${SDKMAN_CANDIDATES_CSV}" | tr ',' ' ') COMPREPLY=( $(compgen -W "$CANDIDATES" -- ${COMP_WORDS[COMP_CWORD]}) ) ;; + "env" ) + COMPREPLY=( $(compgen -W "init" -- ${COMP_WORDS[COMP_CWORD]}) ) + ;; "offline" ) COMPREPLY=( $(compgen -W "enable disable" -- ${COMP_WORDS[COMP_CWORD]}) ) ;; "selfupdate" ) - COMPREPLY=( $(compgen -W "force" -P "[" -S "]" -- ${COMP_WORDS[COMP_CWORD]}) ) + COMPREPLY=( $(compgen -W "force" -- ${COMP_WORDS[COMP_CWORD]}) ) ;; "flush" ) - COMPREPLY=( $(compgen -W "candidates broadcast archives temp" -- ${COMP_WORDS[COMP_CWORD]}) ) + COMPREPLY=( $(compgen -W "archives tmp broadcast version" -- ${COMP_WORDS[COMP_CWORD]}) ) ;; *) ;; esac elif [ $COMP_CWORD -eq 3 ]; then case "${COMP_WORDS[COMP_CWORD-2]}" in - "uninstall" | "rm" | "use" | "default" ) - _sdkman_candidate_versions ${COMP_WORDS[COMP_CWORD-1]} + "uninstall" | "rm" | "use" | "u" | "default" | "d" | "home" | "h" ) + _sdkman_candidate_local_versions ${COMP_WORDS[COMP_CWORD-1]} COMPREPLY=( $(compgen -W "$CANDIDATE_VERSIONS" -- ${COMP_WORDS[COMP_CWORD]}) ) ;; - "install") - _sdkman_candidate_not_installed_versions ${COMP_WORDS[COMP_CWORD-1]} + "install" | "i" ) + _sdkman_candidate_all_versions ${COMP_WORDS[COMP_CWORD-1]} COMPREPLY=( $(compgen -W "$CANDIDATE_VERSIONS" -- ${COMP_WORDS[COMP_CWORD]}) ) ;; *) @@ -43,24 +46,22 @@ _sdkman_complete() return 0 } -_sdkman_candidate_versions(){ +_sdkman_candidate_local_versions(){ - CANDIDATE_LOCAL_VERSIONS=$(__sdkman_cleanup_local_versions $1) - if [ "$SDKMAN_OFFLINE_MODE" = "true" ]; then - CANDIDATE_VERSIONS=$CANDIDATE_LOCAL_VERSIONS - else - CANDIDATE_ONLINE_VERSIONS="$(curl -s "${SDKMAN_SERVICE}/candidates/$1" | tr ',' ' ')" - CANDIDATE_VERSIONS="$(echo $CANDIDATE_ONLINE_VERSIONS $CANDIDATE_LOCAL_VERSIONS |sort | uniq ) " - fi + CANDIDATE_VERSIONS=$(__sdkman_cleanup_local_versions $1) } -_sdkman_candidate_not_installed_versions(){ +_sdkman_candidate_all_versions(){ + CANDIDATE_LOCAL_VERSIONS=$(__sdkman_cleanup_local_versions $1) - if [ "$SDKMAN_OFFLINE_MODE" = "false" ]; then - CANDIDATE_ONLINE_VERSIONS="$(__sdkman_list_versions $1 | grep " " | grep "\." | cut -c 6-)" + if [ "$SDKMAN_OFFLINE_MODE" = "true" ]; then + CANDIDATE_VERSIONS=$CANDIDATE_LOCAL_VERSIONS + else + CANDIDATE_ONLINE_VERSIONS="$(__sdkman_list_versions $1 | grep " " | grep "\." | cut -c 62-)" CANDIDATE_VERSIONS="$(echo $CANDIDATE_ONLINE_VERSIONS $CANDIDATE_LOCAL_VERSIONS | tr ' ' '\n' | sort | uniq -u) " fi + } __sdkman_cleanup_local_versions(){