fix: use old auto-completion for 0.9.x compat
See toolshed/organising#644
Partial revert of 1f8662cd95
This commit is contained in:
@ -1,26 +1,23 @@
|
||||
#compdef abra
|
||||
compdef _abra abra
|
||||
#compdef $PROG
|
||||
|
||||
# https://github.com/urfave/cli/blob/main/autocomplete/zsh_autocomplete
|
||||
_cli_zsh_autocomplete() {
|
||||
|
||||
_abra() {
|
||||
local -a opts
|
||||
local cur
|
||||
cur=${words[-1]}
|
||||
if [[ "$cur" == "-"* ]]; then
|
||||
opts=("${(@f)$(${words[@]:0:#words[@]-1} ${cur} --generate-shell-completion)}")
|
||||
else
|
||||
opts=("${(@f)$(${words[@]:0:#words[@]-1} --generate-shell-completion)}")
|
||||
fi
|
||||
local -a opts
|
||||
local cur
|
||||
cur=${words[-1]}
|
||||
if [[ "$cur" == "-"* ]]; then
|
||||
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} ${cur} --generate-bash-completion)}")
|
||||
else
|
||||
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}")
|
||||
fi
|
||||
|
||||
if [[ "${opts[1]}" != "" ]]; then
|
||||
_describe 'values' opts
|
||||
else
|
||||
_files
|
||||
fi
|
||||
if [[ "${opts[1]}" != "" ]]; then
|
||||
_describe 'values' opts
|
||||
else
|
||||
_files
|
||||
fi
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
# don't run the completion function when being source-ed or eval-ed
|
||||
if [ "$funcstack[1]" = "_abra" ]; then
|
||||
_abra
|
||||
fi
|
||||
compdef _cli_zsh_autocomplete $PROG
|
||||
|
Reference in New Issue
Block a user