-
Notifications
You must be signed in to change notification settings - Fork 1
/
_kitchen
82 lines (66 loc) · 1.9 KB
/
_kitchen
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
70
71
72
73
74
75
76
77
78
79
80
81
82
#compdef kitchen
#autoload
# Kitchen command completion
local -a _1st_arguments
_1st_arguments=(
'console:Kitchen Console!'
'converge:Converge one or more instances'
'create:Create one or more instances'
'destroy:Destroy one or more instances'
'diagnose:Show computed diagnostic configuration'
'driver:Driver subcommands'
'help:Describe available commands or one specific command'
'init:Adds some configuration to your cookbook so Kitchen can rock'
'list:Lists one or more instances'
'login:Log in to one instance'
'setup:Setup one or more instances'
'test:Test one or more instances'
'verify:Verify one or more instances'
'version:Print Kitchen''s version information'
)
__instance_list() {
local cache_policy
zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
if [[ -z "$cache_policy" ]]; then
zstyle ":completion:${curcontext}:" cache-policy _kitchen_list_caching_policy
fi
if ( [[ ${+_kitchen_list} -eq 0 ]] || _cache_invalid kitchen_list ) \
&& ! _retrieve_cache kitchen_list; then
_kitchen_list=(${${(f)"$(command kitchen list -b)"}})
_store_cache kitchen_list _kitchen_list
fi
_wanted application expl 'command' compadd -a _kitchen_list
}
_kitchen_list_caching_policy() {
local -a oldp
oldp=( "$1"(Nmh+1) ) # 1 hour... hopefully ?
(( $#oldp ))
}
__task_list ()
{
local expl
declare -a tasks
tasks=(console converge create destroy diagnose driver init list login setup test verify version)
_wanted tasks expl 'help' compadd $tasks
}
local expl
local curcontext="$curcontext" state line
typeset -A opt_args
_arguments -C \
':command:->command' \
'*::options:->options'
case $state in
(command)
_describe -t commands "gem subcommand" _1st_arguments
return
;;
(options)
case $line[1] in
(help)
_arguments ':feature:__task_list'
;;
(converge|create|destroy|diagnose|list|login|setup|test|verify)
_arguments ':feature:__instance_list'
esac
;;
esac