2019-03-23 14:38:44 -07:00
|
|
|
set -x asdf_data_dir (
|
|
|
|
if test -n "$ASDF_DATA_DIR"; echo $ASDF_DATA_DIR;
|
|
|
|
else; echo $HOME/.asdf; end)
|
|
|
|
|
2016-04-18 00:33:14 -07:00
|
|
|
function __fish_asdf_needs_command
|
|
|
|
set -l cmd (commandline -opc)
|
|
|
|
if test (count $cmd) -eq 1
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
return 1
|
|
|
|
end
|
|
|
|
|
|
|
|
function __fish_asdf_using_command -a current_command
|
|
|
|
set -l cmd (commandline -opc)
|
|
|
|
if test (count $cmd) -gt 1
|
|
|
|
if test $current_command = $cmd[2]
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return 1
|
|
|
|
end
|
|
|
|
|
|
|
|
function __fish_asdf_arg_number -a number
|
|
|
|
set -l cmd (commandline -opc)
|
2017-09-27 00:41:49 -07:00
|
|
|
test (count $cmd) -eq $number
|
2016-04-18 00:33:14 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
function __fish_asdf_arg_at -a number
|
|
|
|
set -l cmd (commandline -opc)
|
2017-09-27 00:41:49 -07:00
|
|
|
echo $cmd[$number]
|
2016-04-18 00:33:14 -07:00
|
|
|
end
|
|
|
|
|
2018-08-24 04:25:38 -07:00
|
|
|
function __fish_asdf_list_versions -a plugin
|
2023-04-16 19:15:46 -07:00
|
|
|
asdf list $plugin 2>/dev/null | string trim | string trim --left --chars '*'
|
2018-11-16 05:25:33 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
function __fish_asdf_list_all -a plugin
|
2023-03-30 00:27:23 -07:00
|
|
|
asdf list-all $plugin 2>/dev/null
|
2018-11-16 05:25:33 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
function __fish_asdf_plugin_list
|
2023-03-30 00:27:23 -07:00
|
|
|
asdf plugin-list 2>/dev/null
|
2018-11-16 05:25:33 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
function __fish_asdf_plugin_list_all
|
2023-03-30 00:27:23 -07:00
|
|
|
asdf plugin-list-all 2>/dev/null
|
2018-08-24 04:25:38 -07:00
|
|
|
end
|
|
|
|
|
2019-03-23 14:38:44 -07:00
|
|
|
function __fish_asdf_list_shims
|
2023-05-31 01:29:50 -07:00
|
|
|
path basename $asdf_data_dir/shims/*
|
2019-03-23 14:38:44 -07:00
|
|
|
end
|
|
|
|
|
2019-03-14 14:29:32 -07:00
|
|
|
# update
|
2023-03-30 00:27:23 -07:00
|
|
|
complete -f -c asdf -n __fish_asdf_needs_command -a update -d "Update asdf"
|
|
|
|
complete -f -c asdf -n '__fish_asdf_using_command update; and __fish_asdf_arg_number 2' -l head -d "Updates to master HEAD"
|
2019-03-14 14:29:32 -07:00
|
|
|
|
2016-04-18 00:33:14 -07:00
|
|
|
# plugin-add completion
|
2023-03-30 00:27:23 -07:00
|
|
|
complete -f -c asdf -n __fish_asdf_needs_command -a plugin-add -d "Add git repo as plugin"
|
2018-11-16 05:25:33 -07:00
|
|
|
complete -f -c asdf -n '__fish_asdf_using_command plugin-add; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list_all | grep -v \'*\' | awk \'{ print $1 }\')'
|
|
|
|
complete -f -c asdf -n '__fish_asdf_using_command plugin-add; and __fish_asdf_arg_number 3' -a '(__fish_asdf_plugin_list_all | grep (__fish_asdf_arg_at 3) | awk \'{ print $2 }\')'
|
2018-08-24 04:25:38 -07:00
|
|
|
complete -f -c asdf -n '__fish_asdf_using_command plugin-add; and __fish_asdf_arg_number 4'
|
2016-04-18 00:33:14 -07:00
|
|
|
|
|
|
|
# plugin-list completion
|
2023-03-30 00:27:23 -07:00
|
|
|
complete -f -c asdf -n __fish_asdf_needs_command -a plugin-list -d "List installed plugins"
|
2016-04-18 00:33:14 -07:00
|
|
|
|
2017-09-27 00:40:50 -07:00
|
|
|
# plugin-list-all completion
|
2023-03-30 00:27:23 -07:00
|
|
|
complete -f -c asdf -n __fish_asdf_needs_command -a plugin-list-all -d "List all existing plugins"
|
2017-09-27 00:40:50 -07:00
|
|
|
|
2016-04-18 00:33:14 -07:00
|
|
|
# plugin-remove completion
|
2023-03-30 00:27:23 -07:00
|
|
|
complete -f -c asdf -n __fish_asdf_needs_command -a plugin-remove -d "Remove plugin and package versions"
|
2018-11-16 05:25:33 -07:00
|
|
|
complete -f -c asdf -n '__fish_asdf_using_command plugin-remove; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)'
|
2016-04-18 00:33:14 -07:00
|
|
|
|
|
|
|
# plugin-update completion
|
2023-03-30 00:27:23 -07:00
|
|
|
complete -f -c asdf -n __fish_asdf_needs_command -a plugin-update -d "Update plugin"
|
2018-11-16 05:25:33 -07:00
|
|
|
complete -f -c asdf -n '__fish_asdf_using_command plugin-update; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)'
|
2016-12-24 16:19:15 -07:00
|
|
|
complete -f -c asdf -n '__fish_asdf_using_command plugin-update; and __fish_asdf_arg_number 2' -a --all
|
2016-04-18 00:33:14 -07:00
|
|
|
|
|
|
|
# install completion
|
2023-03-30 00:27:23 -07:00
|
|
|
complete -f -c asdf -n __fish_asdf_needs_command -a install -d "Install a specific version of a package"
|
2018-11-16 05:25:33 -07:00
|
|
|
complete -f -c asdf -n '__fish_asdf_using_command install; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)'
|
|
|
|
complete -f -c asdf -n '__fish_asdf_using_command install; and __fish_asdf_arg_number 3' -a '(__fish_asdf_list_all (__fish_asdf_arg_at 3))'
|
2016-04-18 00:33:14 -07:00
|
|
|
|
|
|
|
# uninstall completion
|
2023-03-30 00:27:23 -07:00
|
|
|
complete -f -c asdf -n __fish_asdf_needs_command -a uninstall -d "Remove a specific version of a package"
|
2018-11-16 05:25:33 -07:00
|
|
|
complete -f -c asdf -n '__fish_asdf_using_command uninstall; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)'
|
2018-08-24 04:25:38 -07:00
|
|
|
complete -f -c asdf -n '__fish_asdf_using_command uninstall; and __fish_asdf_arg_number 3' -a '(__fish_asdf_list_versions (__fish_asdf_arg_at 3))'
|
2016-04-18 00:33:14 -07:00
|
|
|
|
2016-07-24 08:47:17 -07:00
|
|
|
# current completion
|
2023-03-30 00:27:23 -07:00
|
|
|
complete -f -c asdf -n __fish_asdf_needs_command -a current -d "Display version set or being used for package"
|
2018-11-16 05:25:33 -07:00
|
|
|
complete -f -c asdf -n '__fish_asdf_using_command current; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)'
|
2016-04-18 00:33:14 -07:00
|
|
|
|
|
|
|
# where completion
|
2023-03-30 00:27:23 -07:00
|
|
|
complete -f -c asdf -n __fish_asdf_needs_command -a where -d "Display install path for an installed version"
|
2018-11-16 05:25:33 -07:00
|
|
|
complete -f -c asdf -n '__fish_asdf_using_command where; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)'
|
2018-08-24 04:25:38 -07:00
|
|
|
complete -f -c asdf -n '__fish_asdf_using_command where; and __fish_asdf_arg_number 3' -a '(__fish_asdf_list_versions (__fish_asdf_arg_at 3))'
|
2016-04-18 00:33:14 -07:00
|
|
|
|
2019-03-23 14:38:44 -07:00
|
|
|
# which completion
|
2023-03-30 00:27:23 -07:00
|
|
|
complete -f -c asdf -n __fish_asdf_needs_command -a which -d "Display executable path for a command"
|
2019-03-23 14:38:44 -07:00
|
|
|
complete -f -c asdf -n '__fish_asdf_using_command which; and __fish_asdf_arg_number 2' -a '(__fish_asdf_list_shims)'
|
|
|
|
|
2019-11-22 11:37:52 -07:00
|
|
|
# latest completion
|
2023-03-30 00:27:23 -07:00
|
|
|
complete -f -c asdf -n __fish_asdf_needs_command -a latest -d "Show latest stable version of a package"
|
2019-11-22 11:37:52 -07:00
|
|
|
complete -f -c asdf -n '__fish_asdf_using_command latest; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)'
|
2022-08-22 06:54:10 -07:00
|
|
|
complete -f -c asdf -n '__fish_asdf_using_command latest; and __fish_asdf_arg_number 2' -a --all
|
2019-11-22 11:37:52 -07:00
|
|
|
|
2016-04-18 00:33:14 -07:00
|
|
|
# list completion
|
2023-03-30 00:27:23 -07:00
|
|
|
complete -f -c asdf -n __fish_asdf_needs_command -a list -d "List installed versions of a package"
|
2018-11-16 05:25:33 -07:00
|
|
|
complete -f -c asdf -n '__fish_asdf_using_command list; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)'
|
2016-04-18 00:33:14 -07:00
|
|
|
|
|
|
|
# list-all completion
|
2023-03-30 00:27:23 -07:00
|
|
|
complete -f -c asdf -n __fish_asdf_needs_command -a list-all -d "List all versions of a package"
|
2018-11-16 05:25:33 -07:00
|
|
|
complete -f -c asdf -n '__fish_asdf_using_command list-all; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)'
|
2016-04-18 00:33:14 -07:00
|
|
|
|
|
|
|
# reshim completion
|
2023-03-30 00:27:23 -07:00
|
|
|
complete -f -c asdf -n __fish_asdf_needs_command -a reshim -d "Recreate shims for version of a package"
|
2018-11-16 05:25:33 -07:00
|
|
|
complete -f -c asdf -n '__fish_asdf_using_command reshim; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)'
|
2018-08-24 04:25:38 -07:00
|
|
|
complete -f -c asdf -n '__fish_asdf_using_command reshim; and __fish_asdf_arg_number 3' -a '(__fish_asdf_list_versions (__fish_asdf_arg_at 3))'
|
2016-04-18 00:33:14 -07:00
|
|
|
|
2023-05-31 01:29:50 -07:00
|
|
|
# shim-versions completion
|
|
|
|
complete -f -c asdf -n __fish_asdf_needs_command -a shim-versions -d "List the plugins and versions that provide a command"
|
|
|
|
complete -f -c asdf -n '__fish_asdf_using_command shim-versions; and __fish_asdf_arg_number 2' -a '(__fish_asdf_list_shims)'
|
|
|
|
|
2016-04-24 08:11:33 -07:00
|
|
|
# local completion
|
2023-03-30 00:27:23 -07:00
|
|
|
complete -f -c asdf -n __fish_asdf_needs_command -a local -d "Set local version for a plugin"
|
2018-11-16 05:25:33 -07:00
|
|
|
complete -f -c asdf -n '__fish_asdf_using_command local; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)'
|
2018-08-24 04:25:38 -07:00
|
|
|
complete -f -c asdf -n '__fish_asdf_using_command local; and test (count (commandline -opc)) -gt 2' -a '(__fish_asdf_list_versions (__fish_asdf_arg_at 3)) system'
|
2016-04-24 08:11:33 -07:00
|
|
|
|
|
|
|
# global completion
|
2023-03-30 00:27:23 -07:00
|
|
|
complete -f -c asdf -n __fish_asdf_needs_command -a global -d "Set global version for a plugin"
|
2018-11-16 05:25:33 -07:00
|
|
|
complete -f -c asdf -n '__fish_asdf_using_command global; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)'
|
2018-08-24 04:25:38 -07:00
|
|
|
complete -f -c asdf -n '__fish_asdf_using_command global; and test (count (commandline -opc)) -gt 2' -a '(__fish_asdf_list_versions (__fish_asdf_arg_at 3)) system'
|
2016-04-24 08:11:33 -07:00
|
|
|
|
2019-03-09 10:30:31 -07:00
|
|
|
# shell completion
|
2023-03-30 00:27:23 -07:00
|
|
|
complete -f -c asdf -n __fish_asdf_needs_command -a shell -d "Set version for a plugin in current shell session"
|
2019-03-09 10:30:31 -07:00
|
|
|
complete -f -c asdf -n '__fish_asdf_using_command shell; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)'
|
|
|
|
complete -f -c asdf -n '__fish_asdf_using_command shell; and test (count (commandline -opc)) -gt 2' -a '(__fish_asdf_list_versions (__fish_asdf_arg_at 3)) system'
|
|
|
|
|
2016-04-18 00:33:14 -07:00
|
|
|
# misc
|
2023-03-30 00:27:23 -07:00
|
|
|
complete -f -c asdf -n __fish_asdf_needs_command -l help -d "Displays help"
|
|
|
|
complete -f -c asdf -n __fish_asdf_needs_command -a info -d "Print OS, Shell and ASDF debug information"
|
|
|
|
complete -f -c asdf -n __fish_asdf_needs_command -l version -d "Displays asdf version"
|