-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathitkdev-docker-compose-completion.bash
More file actions
69 lines (55 loc) · 2.27 KB
/
itkdev-docker-compose-completion.bash
File metadata and controls
69 lines (55 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# itkdev-docker-compose completion -*- shell-script -*-
# This bash completions script was generated by
# completely (https://github.com/bashly-framework/completely)
# Modifying it manually is not recommended
_itkdev-docker-compose_completions_filter() {
local words="$1"
local cur=${COMP_WORDS[COMP_CWORD]}
local result=()
# words the user already typed (excluding the command itself)
local used=()
if ((COMP_CWORD > 1)); then
used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
fi
if [[ "${cur:0:1}" == "-" ]]; then
# Completing an option: offer everything (including options)
echo "$words"
else
# Completing a non-option: offer only non-options,
# and don't re-offer ones already used earlier in the line.
for word in $words; do
[[ "${word:0:1}" == "-" ]] && continue
local seen=0
for u in "${used[@]}"; do
if [[ "$u" == "$word" ]]; then
seen=1
break
fi
done
((!seen)) && result+=("$word")
done
echo "${result[*]}"
fi
}
_itkdev-docker-compose_completions() {
local cur=${COMP_WORDS[COMP_CWORD]}
local compwords=()
if ((COMP_CWORD > 0)); then
compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
fi
local compline="${compwords[*]}"
COMPREPLY=()
case "$compline" in
'template:install'*)
while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_itkdev-docker-compose_completions_filter "--force --list $(itkdev-docker-compose template:install --list-compact 2>/dev/null)")" -- "$cur")
;;
'template:update'*)
while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_itkdev-docker-compose_completions_filter "--force")" -- "$cur")
;;
*)
while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_itkdev-docker-compose_completions_filter "--help url open drush self:update sync sync:db sync:files sql:cli sql:connect sql:log sql:open sql:port template:install template:update traefik:start traefik:stop traefik:url traefik:open traefik:logs traefik:pull mail:url mail:open mailhog:url mailhog:open xdebug xdebug3 hosts:insert images:pull shell composer php down version")" -- "$cur")
;;
esac
} &&
complete -F _itkdev-docker-compose_completions itkdev-docker-compose
# ex: filetype=sh