Fix ZSH autocomplete for multiple -f flags

Signed-off-by: Alex Puschinsky <alexpoo@gmail.com>
This commit is contained in:
Alex Puschinsky 2018-11-03 18:09:28 +02:00
parent 2b604c1e8b
commit 5b02922455
1 changed files with 17 additions and 4 deletions

View File

@ -354,7 +354,7 @@ _docker-compose() {
'(-): :->command' \
'(-)*:: :->option-or-argument' && ret=0
local -a relevant_compose_flags relevant_docker_flags compose_options docker_options
local -a relevant_compose_flags relevant_compose_repeatable_flags relevant_docker_flags compose_options docker_options
relevant_compose_flags=(
"--file" "-f"
@ -368,6 +368,10 @@ _docker-compose() {
"--skip-hostname-check"
)
relevant_compose_repeatable_flags=(
"--file" "-f"
)
relevant_docker_flags=(
"--host" "-H"
"--tls"
@ -385,9 +389,18 @@ _docker-compose() {
fi
fi
if [[ -n "${relevant_compose_flags[(r)$k]}" ]]; then
compose_options+=$k
if [[ -n "$opt_args[$k]" ]]; then
compose_options+=$opt_args[$k]
if [[ -n "${relevant_compose_repeatable_flags[(r)$k]}" ]]; then
values=("${(@s/:/)opt_args[$k]}")
for value in $values
do
compose_options+=$k
compose_options+=$value
done
else
compose_options+=$k
if [[ -n "$opt_args[$k]" ]]; then
compose_options+=$opt_args[$k]
fi
fi
fi
done