fix!: align Fish entrypoint behaviour with other shells (#1524)

This commit is contained in:
Edwin Kofler 2023-03-30 00:27:23 -07:00 committed by GitHub
parent b6d0ca28d5
commit 8919f4009e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 62 additions and 62 deletions

View File

@ -9,3 +9,6 @@ insert_final_newline = true
[*.py] [*.py]
indent_size = 4 indent_size = 4
[*.fish]
indent_size = 4

View File

@ -25,6 +25,12 @@ jobs:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Install Fish (for fish_indent)
run: |
sudo add-apt-repository -y ppa:fish-shell/nightly-master
sudo apt-get update
sudo apt-get -y install fish
- name: Install asdf dependencies - name: Install asdf dependencies
uses: asdf-vm/actions/install@v2 uses: asdf-vm/actions/install@v2

View File

@ -1,38 +1,24 @@
if not set -q ASDF_DIR if test -z $ASDF_DIR
set -x ASDF_DIR (dirname (status -f)) set ASDF_DIR (realpath (dirname (status filename)))
end
set --export ASDF_DIR $ASDF_DIR
set -l _asdf_bin "$ASDF_DIR/bin"
if test -z $ASDF_DATA_DIR
set _asdf_shims "$HOME/.asdf/shims"
else
set _asdf_shims "$ASDF_DATA_DIR/shims"
end end
# Add asdf to PATH # Do not use fish_add_path (added in Fish 3.2) because it
# fish_add_path was added in fish 3.2, so we need a fallback for older version # potentially changes the order of items in fish_user_paths
if type -q fish_add_path if not contains $_asdf_bin $fish_user_paths
if test -n "$ASDF_DATA_DIR" set --global --prepend fish_user_paths $_asdf_bin
fish_add_path --global --move "$ASDF_DATA_DIR/shims" "$ASDF_DIR/bin"
else
fish_add_path --global --move "$HOME/.asdf/shims" "$ASDF_DIR/bin"
end
else
set -l asdf_user_shims (
if test -n "$ASDF_DATA_DIR"
printf "%s\n" "$ASDF_DATA_DIR/shims"
else
printf "%s\n" "$HOME/.asdf/shims"
end
)
set -l asdf_bin_dirs $ASDF_DIR/bin $asdf_user_shims
for x in $asdf_bin_dirs
if test -d $x
for i in (seq 1 (count $PATH))
if test $PATH[$i] = $x
set -e PATH[$i]
break
end
end
end
set PATH $x $PATH
end end
if not contains $_asdf_shims $fish_user_paths
set --global --prepend fish_user_paths $_asdf_shims
end end
set --erase _asdf_bin _asdf_shims
# Load the asdf wrapper function # Load the asdf wrapper function
. $ASDF_DIR/lib/asdf.fish . $ASDF_DIR/lib/asdf.fish

View File

@ -51,87 +51,87 @@ function __fish_asdf_list_shims
end end
# update # update
complete -f -c asdf -n '__fish_asdf_needs_command' -a update -d "Update asdf" 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" complete -f -c asdf -n '__fish_asdf_using_command update; and __fish_asdf_arg_number 2' -l head -d "Updates to master HEAD"
# plugin-add completion # plugin-add completion
complete -f -c asdf -n '__fish_asdf_needs_command' -a plugin-add -d "Add git repo as plugin" complete -f -c asdf -n __fish_asdf_needs_command -a plugin-add -d "Add git repo as plugin"
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 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 }\')' 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 }\')'
complete -f -c asdf -n '__fish_asdf_using_command plugin-add; and __fish_asdf_arg_number 4' complete -f -c asdf -n '__fish_asdf_using_command plugin-add; and __fish_asdf_arg_number 4'
# plugin-list completion # plugin-list completion
complete -f -c asdf -n '__fish_asdf_needs_command' -a plugin-list -d "List installed plugins" complete -f -c asdf -n __fish_asdf_needs_command -a plugin-list -d "List installed plugins"
# plugin-list-all completion # plugin-list-all completion
complete -f -c asdf -n '__fish_asdf_needs_command' -a plugin-list-all -d "List all existing plugins" complete -f -c asdf -n __fish_asdf_needs_command -a plugin-list-all -d "List all existing plugins"
# plugin-remove completion # plugin-remove completion
complete -f -c asdf -n '__fish_asdf_needs_command' -a plugin-remove -d "Remove plugin and package versions" complete -f -c asdf -n __fish_asdf_needs_command -a plugin-remove -d "Remove plugin and package versions"
complete -f -c asdf -n '__fish_asdf_using_command plugin-remove; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)' complete -f -c asdf -n '__fish_asdf_using_command plugin-remove; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)'
# plugin-update completion # plugin-update completion
complete -f -c asdf -n '__fish_asdf_needs_command' -a plugin-update -d "Update plugin" complete -f -c asdf -n __fish_asdf_needs_command -a plugin-update -d "Update plugin"
complete -f -c asdf -n '__fish_asdf_using_command plugin-update; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)' complete -f -c asdf -n '__fish_asdf_using_command plugin-update; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)'
complete -f -c asdf -n '__fish_asdf_using_command plugin-update; and __fish_asdf_arg_number 2' -a --all complete -f -c asdf -n '__fish_asdf_using_command plugin-update; and __fish_asdf_arg_number 2' -a --all
# install completion # install completion
complete -f -c asdf -n '__fish_asdf_needs_command' -a install -d "Install a specific version of a package" complete -f -c asdf -n __fish_asdf_needs_command -a install -d "Install a specific version of a package"
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 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))' 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))'
# uninstall completion # uninstall completion
complete -f -c asdf -n '__fish_asdf_needs_command' -a uninstall -d "Remove a specific version of a package" complete -f -c asdf -n __fish_asdf_needs_command -a uninstall -d "Remove a specific version of a package"
complete -f -c asdf -n '__fish_asdf_using_command uninstall; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)' complete -f -c asdf -n '__fish_asdf_using_command uninstall; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)'
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))' 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))'
# current completion # current completion
complete -f -c asdf -n '__fish_asdf_needs_command' -a current -d "Display version set or being used for package" complete -f -c asdf -n __fish_asdf_needs_command -a current -d "Display version set or being used for package"
complete -f -c asdf -n '__fish_asdf_using_command current; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)' complete -f -c asdf -n '__fish_asdf_using_command current; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)'
# where completion # where completion
complete -f -c asdf -n '__fish_asdf_needs_command' -a where -d "Display install path for an installed version" complete -f -c asdf -n __fish_asdf_needs_command -a where -d "Display install path for an installed version"
complete -f -c asdf -n '__fish_asdf_using_command where; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)' complete -f -c asdf -n '__fish_asdf_using_command where; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)'
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))' 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))'
# which completion # which completion
complete -f -c asdf -n '__fish_asdf_needs_command' -a which -d "Display executable path for a command" complete -f -c asdf -n __fish_asdf_needs_command -a which -d "Display executable path for a command"
complete -f -c asdf -n '__fish_asdf_using_command which; and __fish_asdf_arg_number 2' -a '(__fish_asdf_list_shims)' complete -f -c asdf -n '__fish_asdf_using_command which; and __fish_asdf_arg_number 2' -a '(__fish_asdf_list_shims)'
# latest completion # latest completion
complete -f -c asdf -n '__fish_asdf_needs_command' -a latest -d "Show latest stable version of a package" complete -f -c asdf -n __fish_asdf_needs_command -a latest -d "Show latest stable version of a package"
complete -f -c asdf -n '__fish_asdf_using_command latest; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)' complete -f -c asdf -n '__fish_asdf_using_command latest; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)'
complete -f -c asdf -n '__fish_asdf_using_command latest; and __fish_asdf_arg_number 2' -a --all complete -f -c asdf -n '__fish_asdf_using_command latest; and __fish_asdf_arg_number 2' -a --all
# list completion # list completion
complete -f -c asdf -n '__fish_asdf_needs_command' -a list -d "List installed versions of a package" complete -f -c asdf -n __fish_asdf_needs_command -a list -d "List installed versions of a package"
complete -f -c asdf -n '__fish_asdf_using_command list; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)' complete -f -c asdf -n '__fish_asdf_using_command list; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)'
# list-all completion # list-all completion
complete -f -c asdf -n '__fish_asdf_needs_command' -a list-all -d "List all versions of a package" complete -f -c asdf -n __fish_asdf_needs_command -a list-all -d "List all versions of a package"
complete -f -c asdf -n '__fish_asdf_using_command list-all; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)' complete -f -c asdf -n '__fish_asdf_using_command list-all; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)'
# reshim completion # reshim completion
complete -f -c asdf -n '__fish_asdf_needs_command' -a reshim -d "Recreate shims for version of a package" complete -f -c asdf -n __fish_asdf_needs_command -a reshim -d "Recreate shims for version of a package"
complete -f -c asdf -n '__fish_asdf_using_command reshim; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)' complete -f -c asdf -n '__fish_asdf_using_command reshim; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)'
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))' 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))'
# local completion # local completion
complete -f -c asdf -n '__fish_asdf_needs_command' -a local -d "Set local version for a plugin" complete -f -c asdf -n __fish_asdf_needs_command -a local -d "Set local version for a plugin"
complete -f -c asdf -n '__fish_asdf_using_command local; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)' complete -f -c asdf -n '__fish_asdf_using_command local; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)'
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' 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'
# global completion # global completion
complete -f -c asdf -n '__fish_asdf_needs_command' -a global -d "Set global version for a plugin" complete -f -c asdf -n __fish_asdf_needs_command -a global -d "Set global version for a plugin"
complete -f -c asdf -n '__fish_asdf_using_command global; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)' complete -f -c asdf -n '__fish_asdf_using_command global; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)'
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' 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'
# shell completion # shell completion
complete -f -c asdf -n '__fish_asdf_needs_command' -a shell -d "Set version for a plugin in current shell session" complete -f -c asdf -n __fish_asdf_needs_command -a shell -d "Set version for a plugin in current shell session"
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 __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' 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'
# misc # misc
complete -f -c asdf -n '__fish_asdf_needs_command' -l "help" -d "Displays help" 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 -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" complete -f -c asdf -n __fish_asdf_needs_command -l version -d "Displays asdf version"

View File

@ -1,15 +1,14 @@
# The asdf function is a wrapper so we can export variables
# Add function wrapper so we can export variables
function asdf function asdf
set command $argv[1] set command $argv[1]
set -e argv[1] set -e argv[1]
switch "$command" switch "$command"
case "shell" case shell
# source commands that need to export variables # Source commands that need to export variables.
command asdf export-shell-version fish $argv | source # asdf_allow: source command asdf export-shell-version fish $argv | source # asdf_allow: source
case '*' case '*'
# forward other commands to asdf script # Forward other commands to asdf script.
command asdf "$command" $argv command asdf "$command" $argv
end end
end end

View File

@ -23,3 +23,6 @@ shfmt --language-dialect bash --indent 2 --write \
# check .bats files # check .bats files
shfmt --language-dialect bats --indent 2 --write \ shfmt --language-dialect bats --indent 2 --write \
test/*.bats test/*.bats
# check .fish files
fish_indent --write ./**/*.fish

View File

@ -23,3 +23,6 @@ shfmt --language-dialect bash --indent 2 --diff \
# check .bats files # check .bats files
shfmt --language-dialect bats --indent 2 --diff \ shfmt --language-dialect bats --indent 2 --diff \
test/*.bats test/*.bats
# check .fish files
fish_indent --check ./**/*.fish