completion/dotnet: modernize

and `shfmt`
This commit is contained in:
John D Pell
2022-01-12 22:38:51 -08:00
parent 1a48bcc852
commit 77c5f8eda9
2 changed files with 6 additions and 9 deletions

View File

@@ -2,17 +2,13 @@
about-completion "bash parameter completion for the dotnet CLI"
# see https://docs.microsoft.com/en-us/dotnet/core/tools/enable-tab-autocomplete#bash
_dotnet_bash_complete()
{
local word=${COMP_WORDS[COMP_CWORD]}
function _dotnet_bash_complete() {
local cur="${COMP_WORDS[COMP_CWORD]}" IFS=$'\n'
local candidates
local completions
completions="$(dotnet complete --position "${COMP_POINT}" "${COMP_LINE}" 2>/dev/null)"
if [ $? -ne 0 ]; then
completions=""
fi
read -d '' -ra candidates < <(dotnet complete --position "${COMP_POINT}" "${COMP_LINE}" 2> /dev/null)
COMPREPLY=( $(compgen -W "$completions" -- "$word") )
read -d '' -ra COMPREPLY < <(compgen -W "${candidates[*]:-}" -- "$cur")
}
complete -f -F _dotnet_bash_complete dotnet