Skip to content

Commit

Permalink
Merge pull request #1763 from marcospereira/sdkman-update
Browse files Browse the repository at this point in the history
Add support to newer versions of sdkman
  • Loading branch information
Noah Gorny authored Jan 7, 2021
2 parents ae9da3b + 5ca2c43 commit c5f02b7
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions completion/available/sdkman.completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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]}) )
;;
*)
Expand All @@ -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(){
Expand Down

0 comments on commit c5f02b7

Please sign in to comment.