code cleanup of completion logic
This commit is contained in:
@ -1,10 +1,11 @@
|
|||||||
_pulseaudio_tcp_completions() {
|
_pulseaudio_tcp_completions() {
|
||||||
local cur options commands delete all_options command_pattern all_commands
|
local options commands cur delete all_options command_pattern all_commands
|
||||||
|
|
||||||
cur=${COMP_WORDS[COMP_CWORD]}
|
|
||||||
options=( "--debug" "--help" "--nogui" )
|
options=( "--debug" "--help" "--nogui" )
|
||||||
commands=( "start" "stop" "status" "setup" "restart" )
|
commands=( "start" "stop" "status" "setup" "restart" )
|
||||||
|
|
||||||
|
cur=${COMP_WORDS[COMP_CWORD]}
|
||||||
|
|
||||||
for delete in "${COMP_WORDS[@]::${#COMP_WORDS[@]}-1}" ; do
|
for delete in "${COMP_WORDS[@]::${#COMP_WORDS[@]}-1}" ; do
|
||||||
options=("${options[@]/$delete}")
|
options=("${options[@]/$delete}")
|
||||||
commands=("${commands[@]/$delete}")
|
commands=("${commands[@]/$delete}")
|
||||||
@ -21,13 +22,7 @@ _pulseaudio_tcp_completions() {
|
|||||||
all_commands="${commands[*]}"
|
all_commands="${commands[*]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
COMPREPLY=()
|
mapfile -t COMPREPLY < <(compgen -W "$all_options $all_commands" "$cur")
|
||||||
|
|
||||||
case "$cur" in
|
|
||||||
'') mapfile -t COMPREPLY < <(compgen -W "$all_options $all_commands" -- "$cur") ;;
|
|
||||||
-*) mapfile -t COMPREPLY < <(compgen -W "$all_options" -- "$cur") ;;
|
|
||||||
[^-]*) mapfile -t COMPREPLY < <(compgen -W "$all_commands" -- "$cur") ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
} && complete -F _pulseaudio_tcp_completions pulseaudio-tcp
|
} && complete -F _pulseaudio_tcp_completions pulseaudio-tcp
|
||||||
|
Reference in New Issue
Block a user