-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcompletion
46 lines (43 loc) · 836 Bytes
/
completion
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
#!/bin/bash
__get_conainers() {
$1 ps --format '{{.Label "crowdr.name"}}'
}
_crowdr() {
local cur prev
local commands=(
build
run
stop
ps
ip
shell
exec
pipe
restart
start
stats
kill
rm
rmi
version
)
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
case $prev in
shell|pipe|exec)
COMPREPLY=($(compgen -W "$(__get_conainers $1)" -- $cur))
return 0
;;
esac
case $cur in
shell|pipe|exec)
COMPREPLY=($(__get_conainers $1))
;;
*)
COMPREPLY=($(compgen -W "${commands[*]}" -- $cur))
;;
esac
return 0
}
complete -F _crowdr crowdr ./crowdr