mirror of
https://github.com/ethauvin/sdkman-for-fish.git
synced 2025-04-25 13:27:10 -07:00
Propose only installed candidates where appropriate.
Resolves issue #13.
This commit is contained in:
parent
e13d3f2f50
commit
fd1b0b94ce
2 changed files with 18 additions and 12 deletions
|
@ -76,6 +76,12 @@ function __fish_sdkman_candidates
|
||||||
cat ~/.sdkman/var/candidates | tr ',' '\n'
|
cat ~/.sdkman/var/candidates | tr ',' '\n'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function __fish_sdkman_candidates_with_versions
|
||||||
|
find ~/.sdkman/candidates/ -name '*current*' -printf "%h\n" \
|
||||||
|
| cut -d '/' -f 6 \
|
||||||
|
| sort -u
|
||||||
|
end
|
||||||
|
|
||||||
function __fish_sdkman_installed_versions
|
function __fish_sdkman_installed_versions
|
||||||
set cmd (commandline -opc)
|
set cmd (commandline -opc)
|
||||||
if [ -d ~/.sdkman/candidates/$cmd[3]/current ]
|
if [ -d ~/.sdkman/candidates/$cmd[3]/current ]
|
||||||
|
@ -98,7 +104,7 @@ complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 2 i install'
|
||||||
|
|
||||||
# uninstall
|
# uninstall
|
||||||
complete -c sdk -f -n '__fish_sdkman_no_command' -a 'rm uninstall' -d 'Uninstall version'
|
complete -c sdk -f -n '__fish_sdkman_no_command' -a 'rm uninstall' -d 'Uninstall version'
|
||||||
complete -c sdk -f -n '__fish_sdkman_using_command rm uninstall' -a "(__fish_sdkman_candidates)"
|
complete -c sdk -f -n '__fish_sdkman_using_command rm uninstall' -a "(__fish_sdkman_candidates_with_versions)"
|
||||||
complete -c sdk -f -n '__fish_sdkman_specifying_candidate rm uninstall' -a "(__fish_sdkman_installed_versions)"
|
complete -c sdk -f -n '__fish_sdkman_specifying_candidate rm uninstall' -a "(__fish_sdkman_installed_versions)"
|
||||||
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 2 rm uninstall' # block
|
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 2 rm uninstall' # block
|
||||||
|
|
||||||
|
@ -109,13 +115,13 @@ complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 1 ls list' #
|
||||||
|
|
||||||
# use
|
# use
|
||||||
complete -c sdk -f -n '__fish_sdkman_no_command' -a 'u use' -d 'Use specific version'
|
complete -c sdk -f -n '__fish_sdkman_no_command' -a 'u use' -d 'Use specific version'
|
||||||
complete -c sdk -f -n '__fish_sdkman_using_command u use' -a "(__fish_sdkman_candidates)"
|
complete -c sdk -f -n '__fish_sdkman_using_command u use' -a "(__fish_sdkman_candidates_with_versions)"
|
||||||
complete -c sdk -f -n '__fish_sdkman_specifying_candidate u use' -a "(__fish_sdkman_installed_versions)"
|
complete -c sdk -f -n '__fish_sdkman_specifying_candidate u use' -a "(__fish_sdkman_installed_versions)"
|
||||||
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 2 u use' # block
|
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 2 u use' # block
|
||||||
|
|
||||||
# default
|
# default
|
||||||
complete -c sdk -f -n '__fish_sdkman_no_command' -a 'd default' -d 'Set default version'
|
complete -c sdk -f -n '__fish_sdkman_no_command' -a 'd default' -d 'Set default version'
|
||||||
complete -c sdk -f -n '__fish_sdkman_using_command d default' -a "(__fish_sdkman_candidates)"
|
complete -c sdk -f -n '__fish_sdkman_using_command d default' -a "(__fish_sdkman_candidates_with_versions)"
|
||||||
complete -c sdk -f -n '__fish_sdkman_specifying_candidate d default' -a "(__fish_sdkman_installed_versions)"
|
complete -c sdk -f -n '__fish_sdkman_specifying_candidate d default' -a "(__fish_sdkman_installed_versions)"
|
||||||
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 2 d default' # block
|
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 2 d default' # block
|
||||||
|
|
||||||
|
@ -126,7 +132,7 @@ complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 1 c current'
|
||||||
|
|
||||||
# upgrade
|
# upgrade
|
||||||
complete -c sdk -f -n '__fish_sdkman_no_command' -a 'ug upgrade' -d 'Display what is outdated'
|
complete -c sdk -f -n '__fish_sdkman_no_command' -a 'ug upgrade' -d 'Display what is outdated'
|
||||||
complete -c sdk -f -n '__fish_sdkman_using_command ug upgrade' -a "(__fish_sdkman_candidates)"
|
complete -c sdk -f -n '__fish_sdkman_using_command ug upgrade' -a "(__fish_sdkman_candidates_with_versions)"
|
||||||
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 1 ug upgrade' # block
|
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 1 ug upgrade' # block
|
||||||
|
|
||||||
# version
|
# version
|
||||||
|
|
|
@ -40,7 +40,7 @@ test_cases = {
|
||||||
"install 1." => [],
|
"install 1." => [],
|
||||||
|
|
||||||
"uninstall " => ["ant"],
|
"uninstall " => ["ant"],
|
||||||
"uninstall an" => ["ant"],
|
"uninstall a" => ["ant"],
|
||||||
"uninstall j" => [],
|
"uninstall j" => [],
|
||||||
"uninstall 1." => [],
|
"uninstall 1." => [],
|
||||||
|
|
||||||
|
@ -87,19 +87,19 @@ test_cases = {
|
||||||
"update a" => [],
|
"update a" => [],
|
||||||
|
|
||||||
"flush " => ["broadcast", "archives", "temp"],
|
"flush " => ["broadcast", "archives", "temp"],
|
||||||
"flush a" => [],
|
"flush x" => [],
|
||||||
|
|
||||||
# Third parameters complete correctly
|
# Third parameters complete correctly
|
||||||
#"install ant 1.10." => ["1.10.0", "1.10.1"], # TODO: issue #4
|
#"install ant 1.10." => ["1.10.0", "1.10.1"], # TODO: issue #4
|
||||||
"uninstall ant 1.10." => ["1.10.1"],
|
"uninstall ant 1.10." => ["1.10.1"],
|
||||||
"list " => [],
|
"list ant " => [],
|
||||||
"use ant " => ["1.9.9", "1.10.1"],
|
"use ant " => ["1.9.9", "1.10.1"],
|
||||||
"default ant " => ["1.9.9", "1.10.1"],
|
"default ant " => ["1.9.9", "1.10.1"],
|
||||||
"current " => [],
|
"current ant " => [],
|
||||||
"upgrade " => [],
|
"upgrade ant " => [],
|
||||||
"offline " => [],
|
"offline ant " => [],
|
||||||
"selfupdate " => [],
|
"selfupdate ant " => [],
|
||||||
"flush " => [],
|
"flush ant " => [],
|
||||||
|
|
||||||
# Fourth parameters complete correctly
|
# Fourth parameters complete correctly
|
||||||
"install ant 1.10.2 " => [],
|
"install ant 1.10.2 " => [],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue