-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathuppm-zsh-completion
248 lines (235 loc) · 10.4 KB
/
uppm-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
#compdef uppm
_commands=(
'-h:show help of this command.'
'--help:show help of this command.'
'-V:show version of this.'
'--version:show version of this command.'
'about:show information about this software.'
'sysinfo:show basic information about your current running operation system.'
'search:search packages whose name match the given keyword.'
'info-available:show infomation of the given available package.'
'info-installed:show infomation of the given installed package.'
'formula-view:view the formula of the given package.'
'formula-edit:edit the formula of the given package.'
'tree:list files of the given installed package in a tree-like format.'
'depends:show the packages that are depended by the given package.'
'fetch:download the prebuild binary archive of the given package to the local cache.'
'install:install packages.'
'reinstall:reinstall packages.'
'uninstall:uninstall packages.'
'cleanup:cleanup the unused cache.'
'update:update the formula repositories.'
'upgrade:upgrade the outdated packages.'
'upgrade-self:upgrade this software.'
'integrate:integrate zsh completions.'
'gen-url-transform-sample:generate url-transform sample'
'formula-repo-add:create a new empty formula repository then sync with server.'
'formula-repo-del:delete the given formula repository.'
'formula-repo-init:create a new empty formula repository.'
'formula-repo-sync:sync the given formula repository with server.'
'formula-repo-conf:change the config of the given formula repository.'
'formula-repo-info:show infomation of the given formula repository.'
'formula-repo-list:list all available formula repositories.'
'ls-available:list the available packages.'
'ls-installed:list the installed packages.'
'ls-outdated:list the installed packages that can be upgraded.'
'is-available:is the given package available.'
'is-installed:is the given package installed.'
'is-outdated:is the given package outdated.'
'util:extra utilities.'
)
function _uppm_commands() {
_describe 'command' _commands
}
function _uppm_available_packages() {
local -a _available_packages
_available_packages=($(uppm ls-available 2>/dev/null))
_describe 'available-packages' _available_packages
}
function _uppm_installed_packages() {
local -a _installed_packages
_installed_packages=($(uppm ls-installed 2>/dev/null))
_describe 'installed-packages' _installed_packages
}
function _uppm_outdated_packages() {
local -a _outdated_packages
_outdated_packages=($(uppm ls-outdated 2>/dev/null | cut -d ' ' -f1))
_describe 'outdated-packages' _outdated_packages
}
function _uppm() {
local context state state_descr line
typeset -A opt_args
_arguments \
'1: :_uppm_commands' \
'*:: :->option'
case $state in
option)
case $words[1] in
formula-view)
_arguments \
'1:package-name:_uppm_available_packages' \
'--no-color[disables color highlighting]'
;;
formula-edit)
_arguments \
'1:package-name:_uppm_available_packages' \
'--editor=-[specify editor]:editor:{_files -/}'
;;
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:($(uppm 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:($(uppm formula-repo-list | sed -n "/^name: /p" | cut -c7-))'
;;
formula-repo-sync)
_arguments '1:formula-repo-name:($(uppm formula-repo-list | sed -n "/^name: /p" | cut -c7-))'
;;
formula-repo-info)
_arguments '1:formula-repo-name:($(uppm formula-repo-list | sed -n "/^name: /p" | cut -c7-))'
;;
integrate)
_arguments \
'1:what:(zsh)' \
'--output-dir=-[set the output dir]:output-dir:{_files -/}' \
'-v[verbose mode]'
;;
info-available)
_arguments \
'1:package-name:_uppm_available_packages' \
'2:key:(summary version license webpage bin-url bin-sha bin-ft bin-fp dep-pkg unpackd install --json --yaml --shell formula)'
;;
info-installed)
_arguments \
'1:package-name:_uppm_installed_packages' \
'2:key:(summary version license webpage bin-url bin-sha dep-pkg unpackd install --json --yaml --shell --prefix --files timestamp-unix timestamp-rfc-3339 timestamp-iso-8601)'
;;
tree)
_arguments \
'1:package-name:_uppm_installed_packages' \
'-L[level]:level:(3)' \
'--dirsfirst[show dirs first]'
;;
fetch)
_arguments ':package-name:(@all $(uppm ls-available 2>/dev/null))'
;;
depends)
_arguments \
'1:package-name:_uppm_available_packages' \
'-t[set output type]:output-type:(dot box png svg)' \
'-o[set output filepath or directory]:output-path:{_files}'
;;
install)
_arguments \
'*:package-name:_uppm_available_packages' \
'-v[verbose mode. many messages will be output to terminal]' \
'-q[silent mode. no any messages will be output to terminal]'
;;
reinstall)
_arguments \
'*:package-name:_uppm_installed_packages' \
'-v[verbose mode. many messages will be output to terminal]' \
'-q[silent mode. no any messages will be output to terminal]'
;;
uninstall)
_arguments \
'*:package-name:_uppm_installed_packages' \
'-v[verbose mode. many messages will be output to terminal]' \
'-q[silent mode. no any messages will be output to terminal]'
;;
upgrade)
_arguments \
'*:package-name:_uppm_outdated_packages' \
'-v[verbose mode. many messages will be output to terminal]' \
'-q[silent mode. no any messages will be output to terminal]'
;;
search)
_arguments \
'1:reg:()' \
'-v[verbose mode]'
;;
ls-available)
_arguments '-v[verbose mode]'
;;
ls-installed)
_arguments '-v[verbose mode]'
;;
ls-outdated)
_arguments '-v[verbose mode]'
;;
is-available)
_arguments \
'1:package-name:_uppm_available_packages'
;;
is-installed)
_arguments \
'1:package-name:_uppm_installed_packages'
;;
is-outdated)
_arguments \
'1:package-name:_uppm_outdated_packages'
;;
util)
_arguments \
'1:utility:(base16-encode base16-decode base64-encode base64-decode sha256sum zlib-deflate zlib-inflate which)' \
'*:: :->utility-option'
if [ "$state" = 'utility-option' ] ; then
case $words[1] in
base16-encode)
;;
base16-decode)
;;
base64-encode)
;;
base64-decode)
;;
zlib-deflate)
_arguments '-L[level]:level:(1 2 3 4 5 6 7 8 9)'
;;
zlib-inflate)
;;
which)
_arguments '1:cmd:()' '-a[find all]'
;;
esac
fi
;;
*) ;;
esac
;;
*);;
esac
}
_uppm "$@"