-
Notifications
You must be signed in to change notification settings - Fork 2
/
_autopkg
185 lines (162 loc) · 6.58 KB
/
_autopkg
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#compdef autopkg
#autoload
#(c) Ben Goodstein 2015
#
# autopkg completion script for zsh
_autopkg_installed_recipes() {
recipes=(${(f)"$(_call_program recipes autopkg list-recipes 2>/dev/null)"})
}
_autopkg_installed_install_recipes(){
recipes=(${(f)"$(_call_program recipes autopkg list-recipes\|grep .install$ 2>/dev/null)"})
}
_autopkg_installed_or_file() {
local expl ret=1
_tags recipe_files recipes
_autopkg_installed_recipes
while _tags; do
_requested recipe_files expl '.recipe files' _files -g '*.recipe' && ret=0
_requested recipes expl 'recipes' compadd -a recipes && ret=0
((ret)) || break
done
return ret
}
__info() {
_arguments \
'(-h,--help)'{-h,--help}'[show help on info command and exit]' \
'(-d,--search-dir=)'{-d,--search-dir=}'[Directory to search for recipes.]:directory:_files -/' \
'--override-dir=[Directory to search for recipe overrides.]:directory:_files -/' \
'1: :->forms' && return 0
if [[ "$state" == forms ]]; then
_autopkg_installed_or_file
fi
}
__install() {
_arguments \
'(-h,--help)'{-h,--help}'[show help on install command and exit]' \
'(--post=,--postprocessor=)'{--post=,--postprocessor=}'[Name of a processor to run after each recipe.]:file:_files' \
'(-c,--check)'{-c,--check}'[Only check for new/changed downloads.]' \
'(-k,--key=)'{-k,--key=}'[ Provide key/value pairs for recipe input.]' \
'(-l,--recipe-list=)'{-l,--recipe-list=}'[Path to a text file with a list of recipes to run.]:file:_files' \
'(-p,--pkg=)'{-p,--pkg=}'[Path to a pkg or dmg to provide to a recipe. Downloading will be skipped.]:file:_files' \
'--report-plist=[File path to save run report plist.]:directory:_files' \
'(-v,--verbose)'{-v,--verbose}'[Verbose output.]' \
'(-d,--search-dir=)'{-d,--search-dir=}'[Directory to search for recipes.]:directory:_files -/' \
'--override-dir=[Directory to search for recipe overrides.]:directory:_files -/' \
'1: :->forms' && return 0
if [[ "$state" == forms ]]; then
_autopkg_installed_install_recipes
_wanted recipes expl 'install recipes' compadd -a recipes
fi
}
__list-recipes() {
_arguments \
'(-h,--help)'{-h,--help}'[show help on list-recipes command and exit]' \
'(-i,--with-identifiers)'{-i,--with-identifiers}'[Include recipe'\''s identifier in the list.]' \
'(-p,--with-paths)'{-p,--with-paths}'[Include recipe'\''s path in the list.]' \
'--plist[Print recipe list in plist format. This provides all available key/value pairs of recipes.]' \
'(-a,--show-all)'{-a,--show-all}'[Include recipes with duplicate shortnames, including overrides.]' \
'(-d,--search-dir=)'{-d,--search-dir=}'[Directory to search for recipes.]:directory:_files -/' \
'--override-dir=[Directory to search for recipe overrides.]:directory:_files -/'
}
__make-override() {
_arguments \
'(-h,--help)'{-h,--help}'[show help on make-override command and exit]' \
'(-d,--search-dir=)'{-d,--search-dir=}'[Directory to search for recipes.]:directory:_files -/' \
'--override-dir=[Directory to search for recipe overrides.]:directory:_files -/' \
'(-n,--name=)'{-n,--name}'[Name for override file.]' \
'1: :->forms' && return 0
if [[ "$state" == forms ]]; then
_autopkg_installed_recipes
_wanted recipes expl 'recipes' compadd -a recipes
fi
}
__processor-info() {
_arguments \
'(-h,--help)'{-h,--help}'[show help on processor-info command and exit]' \
'(-r,--recipe=)'{-r,--recipe=}'[Name of recipe using the processor.]' \
'(-d,--search-dir=)'{-d,--search-dir=}'[Directory to search for recipes.]:directory:_files -/' \
'--override-dir=[Directory to search for recipe overrides.]:directory:_files -/'
}
__repo-add() {
_arguments \
'(-h,--help)'{-h,--help}'[show help on repo-add command and exit]'
}
__repo-delete() {
_arguments \
'(-h,--help)'{-h,--help}'[show help on repo-delete command and exit]'
}
__repo-update() {
_arguments \
'(-h,--help)'{-h,--help}'[show help on repo-update command and exit]'
}
__run() {
_arguments \
'(-h,--help)'{-h,--help}'[show help on install command and exit]' \
'(--post=,--postprocessor=)'{--post=,--postprocessor=}'[Name of a processor to run after each recipe.]:file:_files' \
'(-c,--check)'{-c,--check}'[Only check for new/changed downloads.]' \
'(-k,--key=)'{-k,--key=}'[ Provide key/value pairs for recipe input.]' \
'(-l,--recipe-list=)'{-l,--recipe-list=}'[Path to a text file with a list of recipes to run.]:file:_files' \
'(-p,--pkg=)'{-p,--pkg=}'[Path to a pkg or dmg to provide to a recipe. Downloading will be skipped.]:file:_files' \
'--report-plist=[File path to save run report plist.]:directory:_files' \
'(-v,--verbose)'{-v,--verbose}'[Verbose output.]' \
'(-d,--search-dir=)'{-d,--search-dir=}'[Directory to search for recipes.]:directory:_files -/' \
'--override-dir=[Directory to search for recipe overrides.]:directory:_files -/' \
'1: :->forms' && return 0
if [[ "$state" == forms ]]; then
_autopkg_installed_or_file
fi
}
__search() {
_arguments \
'(-h,--help)'{-h,--help}'[show help on search command and exit]' \
'(-u,--user=)'{-u,--user}'[Alternate GitHub user whose repos to search. Defaults to '\''autopkg'\''.]' \
'(-p,--path-only)'{-p,--path-only}'[Restrict search results to the recipe'\''s path only.]' \
'(-t,--use-token)'{-t,--use-token}'[Use a public-scope GitHub token for a higher rate limit.]'
}
local expl
local -a recipes installed_recipes
local -a _1st_arguments
_1st_arguments=(
'help:Display help'
'info:Get info about configuration or a recipe'
'install:Run one or more install recipes'
'list-processors:List available core processors'
'list-recipes:List recipes available locally'
'make-override:Make a recipe override'
'processor-info:Get information about a specific processor'
'repo-add:Add one or more recipe repo from a URL'
'repo-delete:Delete a recipe repo'
'repo-list:List installed recipe repos'
'repo-update:Update one or more recipe repos'
'run:Run one or more recipes'
'search:Search for recipes on github'
'version:Print the current version of autopkg'
)
_arguments '*:: :->command'
if (( CURRENT == 1 )); then
_describe -t commands "autopkg subcommands" _1st_arguments
return
fi
local -a _command_args
case "$words[1]" in
info)
__info ;;
install)
__install ;;
list-recipes)
__list-recipes ;;
make-override)
__make-override ;;
processor-info)
__processor-info ;;
repo-add)
__repo-add ;;
repo-delete)
__repo-delete ;;
repo-update)
__repo-update ;;
run)
__run ;;
search)
__search ;;
esac