-
Notifications
You must be signed in to change notification settings - Fork 3
/
xcpkg-zsh-completion
315 lines (303 loc) · 17.4 KB
/
xcpkg-zsh-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
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
#compdef xcpkg
_xcpkg_actions=(
'-h:show help of this command.'
'--help:show help of this command.'
'-V:show version of this command.'
'--version:show version of this command.'
'gen-url-transform-sample:generate url-transform sample.'
'setup:install essential tools.'
'about:show basic information about this software.'
'sysinfo:show basic information about your current running operation system.'
'xcinfo:show Xcode information.'
'integrate:integrate zsh completions.'
'cleanup:delete the unused cached files.'
'ls-available:list the available packages.'
'ls-installed:list the installed packages.'
'ls-outdated:list the installed packages which can be upgraded.'
'is-available:is the given package available.'
'is-installed:is the given package installed.'
'is-outdated:is the given package outdated.'
'formula-repo-init:create a new empty formula repository.'
'formula-repo-add:create a new empty formula repository then sync with server.'
'formula-repo-del:delete the given formula repository from your local cache.'
'formula-repo-sync:sync the given formula repository.'
'formula-repo-conf:change the config of the given formula repository.'
'formula-repo-info:show information of the given formula repository.'
'formula-repo-list:list all available formula repositories.'
'search:search packages can be installed.'
'info-available:show information of the given available package.'
'info-installed:show information of the given installed package.'
'depends:show depends of the given package.'
'fetch:download formula resources of the given package to the cache.'
'install:install packages.'
'reinstall:reinstall packages.'
'uninstall:uninstall packages.'
'update:update the formula repository.'
'upgrade:upgrade the outdated packages.'
'upgrade-self:upgrade this software.'
'tree:list installed files of the given installed package in a tree-like format.'
'logs:show logs of the given installed package.'
'pack:pack all the installed files of the given installed package to a single archive file.'
)
function _xcpkg_available_packages() {
local -a _available_packages
_available_packages=($(xcpkg ls-available 2>/dev/null))
_describe 'available-packages' _available_packages
}
function _xcpkg_installed_packages() {
local -a _installed_packages
_installed_packages=($(xcpkg ls-installed 2>/dev/null | sed 's|:|\\:|g'))
_describe 'installed-packages' _installed_packages
}
function _xcpkg_outdated_packages() {
local -a _outdated_packages
_outdated_packages=($(xcpkg ls-outdated 2>/dev/null | sed 's|:|\\:|g'))
_describe 'outdated-packages' _outdated_packages
}
function _xcpkg() {
local context state state_descr line
typeset -A opt_args
_arguments \
'1: :{_describe xcpkg_actions _xcpkg_actions}' \
'*:: :->option'
case $state in
option)
case $words[1] in
ls-target-platform-versions)
_arguments ':platform:($(xcpkg ls-target-platform-names))'
;;
ls-target-platform-archs)
_arguments \
':platform:($(xcpkg ls-target-platform-names))' \
':bit:(64bit 32bit all)'
;;
formula-repo-add)
_arguments \
'1:formula-repo-name:(name)' \
'2:formula-repo-url:(https://)' \
'--branch=-[change the formula repo branch]' \
+ '(pin)' \
'--pin[set pinned to 1]' \
'--unpin[set pinned to 0]' \
+ '(enable)' \
'--enable[set enabled to 1]' \
'--disable[set enabled to 0]'
;;
formula-repo-init)
_arguments \
'1:formula-repo-name:(name)' \
'2:formula-repo-url:(https://)' \
'--branch=-[change the formula repo branch]' \
+ '(pin)' \
'--pin[set pinned to 1]' \
'--unpin[set pinned to 0]' \
+ '(enable)' \
'--enable[set enabled to 1]' \
'--disable[set enabled to 0]'
;;
formula-repo-conf)
_arguments \
'1:formula-repo-name:($(xcpkg formula-repo-list | sed -n "/^name: /p" | cut -c7-))' \
'--url=-[change the formula repo url]' \
'--branch=-[change the formula repo branch]' \
+ '(pin)' \
'--pin[set pinned to yes]' \
'--unpin[set pinned to no]' \
+ '(enable)' \
'--enable[set enabled to yes]' \
'--disable[set enabled to no]'
;;
formula-repo-del)
_arguments '1:formula-repo-name:($(xcpkg formula-repo-list | sed -n "/^name: /p" | cut -c7-))'
;;
formula-repo-sync)
_arguments '1:formula-repo-name:($(xcpkg formula-repo-list | sed -n "/^name: /p" | cut -c7-))'
;;
formula-repo-info)
_arguments '1:formula-repo-name:($(xcpkg formula-repo-list | sed -n "/^name: /p" | cut -c7-))'
;;
info-available)
_arguments \
'1:package-name:_xcpkg_available_packages' \
'2:key:(--yaml --json pkgtype summary version license web-url git-url git-sha git-ref git-nth src-url src-uri src-sha fix-url fix-uri fix-sha fix-opt res-url res-uri res-sha dep-pkg dep-upp dep-pym dep-plm ccflags xxflags ppflags ldflags bscript binbstd bsystem onstart onready onfinal dopatch prepare install dotweak caveats patches reslist symlink parallel developer)'
;;
info-installed)
_arguments \
'1:package-name:_xcpkg_installed_packages' \
'2:key:(--yaml --json pkgtype summary version license web-url git-url git-sha git-ref git-nth src-url src-uri src-sha fix-url fix-uri fix-sha fix-opt res-url res-uri res-sha dep-pkg dep-upp dep-pym dep-plm ccflags xxflags ppflags ldflags bscript binbstd bsystem onstart onready onfinal dopatch prepare install dotweak caveats patches reslist symlink --prefix --files builtby builtat builtat-rfc-3339 builtat-rfc-3339-utc builtat-iso-8601 builtat-iso-8601-utc builtfor parallel developer)'
;;
fetch)
_arguments \
'1:package-name:_xcpkg_available_packages'
;;
depends)
_arguments \
'1:package-name:_xcpkg_available_packages' \
'-t[specify output format]:output-type:(d2 dot box svg png)' \
'-o[specify output filepath or directory]:output-path:_files'
;;
pack)
_arguments \
'1:package-name:_xcpkg_installed_packages' \
'-t[specify output type]:output-type:(zip tar.gz tar.xz tar.lz tar.bz2)' \
'-o[specify output filepath or directory]:output-path:_files' \
'-K[keep the session directory even if successfully packed]'
;;
tree)
_arguments \
'1:package-name:_xcpkg_installed_packages' \
'-a[show all files, including hidden ones]' \
'--dirsfirst[list directories before files]' \
'-L[level]:level:(3)'
;;
logs)
_arguments \
'1:package-name:_xcpkg_installed_packages'
;;
install)
_arguments \
':package-name:_xcpkg_available_packages' \
'--target=-[specify the target to be built for]:target:(MacOSX-10.15-x86_64 MacOSX-13.0-arm64 iPhoneOS-12.0-arm64)' \
'--profile=-[specify build profile]:profile:(debug release)' \
'--developer-dir=-[specify the developer dir]:developer-dir:{_files -/}' \
'-j[specify the number of jobs you can run in parallel]:jobs:(1 2 3 4 5 6 7 8 9)' \
'-I[specify the formula search directory]:search-dir:_path_files -/' \
'-U[upgrade if possible]' \
'-K[keep the session directory even if successfully installed]' \
'-E[export compile_commands.json]' \
'--disable-ccache[do not use ccache]' \
'-v-env[show all environment variables before starting to build]' \
'-v-http[show http request/response]' \
'-v-xcode[show xcode information]' \
'-v-formula[show formula content]' \
'-v-go[pass -v argument to go build command]' \
'-v-uppm[pass -v argument to uppm command]' \
'-v-cargo[pass -v argument to cargo command]' \
'-v-meson[pass -v argument to meson command]' \
'-v-ninja[pass -v argument to ninja command]' \
'-v-gmake[pass V=1 argument to gmake command]' \
'-v-xmake[pass -v argument to xmake command]' \
'-v-cmake[pass -DCMAKE_VERBOSE_MAKEFILE argument to cmake command]' \
'-x-sh[set -x to debug current running shell]' \
'-x-cc[pass -v argument to clang command]' \
'-x-ld[pass -Wl,-v argument to linker]' \
'-x-go[pass -x argument to go build command]' \
'-x-cargo[pass -vv argument to cargo command]' \
'-x-gmake[pass --debug argument to gmake command]' \
'-x-cmake[pass -DCMAKE_FIND_DEBUG_MODE=ON argument to cmake command]' \
'-x-xmake[pass -vD argument to xmake command]' \
'-x-pkg-config[export PKG_CONFIG_DEBUG_SPEW=1]' \
+ '(verbose_level)' \
'-x[very verbose mode. equivalent to -v-* and -x-* options all are supplied]' \
'-v[verbose mode. equivalent to -v-* options all are supplied]' \
'-q[silent mode.]'
;;
reinstall)
_arguments \
':package-name:_xcpkg_installed_packages' \
'--target=-[specify the target to be built for]:target:(MacOSX-10.15-x86_64 MacOSX-13.0-arm64 iPhoneOS-12.0-arm64)' \
'--profile=-[specify build profile]:profile:(debug release)' \
'--developer-dir=-[specify the developer dir]:developer-dir:{_files -/}' \
'-j[specify the number of jobs you can run in parallel]:jobs:(1 2 3 4 5 6 7 8 9)' \
'-I[specify the formula search directory]:search-dir:_path_files -/' \
'-U[upgrade if possible]' \
'-K[keep the session directory even if successfully installed]' \
'-E[export compile_commands.json]' \
'--disable-ccache[do not use ccache]' \
'-v-env[show all environment variables before starting to build]' \
'-v-http[show http request/response]' \
'-v-xcode[show xcode information]' \
'-v-formula[show formula content]' \
'-v-go[pass -v argument to go build command]' \
'-v-uppm[pass -v argument to uppm command]' \
'-v-ninja[pass -v argument to ninja command]' \
'-v-meson[pass -v argument to meson command]' \
'-v-cargo[pass -v argument to cargo command]' \
'-v-gmake[pass V=1 argument to gmake command]' \
'-v-xmake[pass -v argument to xmake command]' \
'-v-cmake[pass -DCMAKE_VERBOSE_MAKEFILE argument to cmake command]' \
'-x-sh[set -x to debug current running shell]' \
'-x-go[pass -x argument to go build command]' \
'-x-cc[pass -v argument to clang command]' \
'-x-ld[pass -Wl,-v argument to linker]' \
'-x-cargo[pass -vv argument to cargo command]' \
'-x-gmake[pass --debug argument to gmake command]' \
'-x-cmake[pass -DCMAKE_FIND_DEBUG_MODE=ON argument to cmake command]' \
'-x-xmake[pass -vD argument to xmake command]' \
'-x-pkg-config[export PKG_CONFIG_DEBUG_SPEW=1]' \
+ '(verbose_level)' \
'-x[very verbose mode. equivalent to -v-* and -x-* options all are supplied]' \
'-v[verbose mode. equivalent to -v-* options all are supplied]' \
'-q[silent mode.]'
;;
upgrade)
_arguments \
':package-name:_xcpkg_outdated_packages' \
'--target=-[specify the target to be built for]:target:(MacOSX-10.15-x86_64 MacOSX-13.0-arm64 iPhoneOS-12.0-arm64)' \
'--profile=-[specify build profile]:profile:(debug release)' \
'--developer-dir=-[specify the developer dir]:developer-dir:{_files -/}' \
'-j[specify the number of jobs you can run in parallel]:jobs:(1 2 3 4 5 6 7 8 9)' \
'-I[specify the formula search directory]:search-dir:_path_files -/' \
'-U[upgrade if possible]' \
'-K[keep the session directory even if successfully installed]' \
'-E[export compile_commands.json]' \
'--disable-ccache[do not use ccache]' \
'-v-env[show all environment variables before starting to build]' \
'-v-http[show http request/response]' \
'-v-xcode[show xcode information]' \
'-v-formula[show formula content]' \
'-v-go[pass -v argument to go build command]' \
'-v-uppm[pass -v argument to uppm command]' \
'-v-ninja[pass -v argument to ninja command]' \
'-v-meson[pass -v argument to meson command]' \
'-v-cargo[pass -v argument to cargo command]' \
'-v-gmake[pass V=1 argument to gmake command]' \
'-v-xmake[pass -v argument to xmake command]' \
'-v-cmake[pass -DCMAKE_VERBOSE_MAKEFILE argument to cmake command]' \
'-x-sh[set -x to debug current running shell]' \
'-x-cc[pass -v argument to clang command]' \
'-x-ld[pass -Wl,-v argument to linker]' \
'-x-go[pass -x argument to go build command]' \
'-x-cargo[pass -vv argument to cargo command]' \
'-x-gmake[pass --debug argument to gmake command]' \
'-x-cmake[pass -DCMAKE_FIND_DEBUG_MODE=ON argument to cmake command]' \
'-x-xmake[pass -vD argument to xmake command]' \
'-x-pkg-config[export PKG_CONFIG_DEBUG_SPEW=1]' \
+ '(verbose_level)' \
'-x[very verbose mode. equivalent to -v-* and -x-* options all are supplied]' \
'-v[verbose mode. equivalent to -v-* options all are supplied]' \
'-q[silent mode.]'
;;
uninstall)
_arguments '*:package-name:_xcpkg_installed_packages'
;;
is-available)
_arguments '1:package-name:_xcpkg_available_packages'
;;
is-installed)
_arguments '1:package-name:_xcpkg_installed_packages'
;;
is-outdated)
_arguments '1:package-name:_xcpkg_outdated_packages'
;;
ls-available)
_arguments '1:package-name:_xcpkg_available_packages' '-v[verbose mode]'
;;
ls-installed)
_arguments '1:package-name:_xcpkg_installed_packages' '-v[verbose mode]'
;;
ls-outdated)
_arguments '1:package-name:_xcpkg_outdated_packages' '-v[verbose mode]'
;;
integrate)
_arguments '1:reg:()' '-v[verbose mode]'
;;
integrate)
_arguments '1:what:(zsh)'
;;
esac
;;
*);;
esac
}
_xcpkg "$@"