-
Notifications
You must be signed in to change notification settings - Fork 0
/
zsh-bw-completion.plugin.zsh
246 lines (223 loc) · 5.88 KB
/
zsh-bw-completion.plugin.zsh
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
#compdef bw
_bw() {
local line
_commands() {
local -a commands
commands=(
"login:Log into a user account."
"logout:Log out of the current user account."
"lock:Lock the vault and destroy active session keys."
"unlock:Unlock the vault and return a new session key."
"sync:Pull the latest vault data from server."
"list:List an array of objects from the vault."
"get:Get an object from the vault."
"create:Create an object in the vault."
"edit:Edit an object from the vault."
"delete:Delete an object from the vault."
"share:Share an item to an organization."
"import:Import vault data from a file."
"export:Export vault data to a CSV or JSON file."
"generate:Generate a password/passphrase."
"encode:Base 64 encode stdin."
"config:Configure CLI settings."
"update:Check for updates."
)
_describe 'command' commands
}
_arguments -C \
"--pretty[Format output. JSON is tabbed with two spaces.]" \
"--raw[Return raw output instead of a descriptive message.]" \
"--response[Return a JSON formatted version of response output.]" \
"--quiet[Don't return anything to stdout.]" \
"--session[Pass session key instead of reading from env.]" \
{-v,--version}"[output the version number]" \
{-h,--help}"[output usage information]" \
"1: :_commands" \
"*::arg:->args"
case $line[1] in
login)
_bw_login
;;
logout)
_bw_logout
;;
lock)
_bw_lock
;;
unlock)
_bw_unlock
;;
sync)
_bw_sync
;;
list)
_bw_list
;;
get)
_bw_get
;;
create)
_bw_create
;;
edit)
_bw_edit
;;
delete)
_bw_delete
;;
share)
_bw_share
;;
import)
_bw_import
;;
export)
_bw_export
;;
generate)
_bw_generate
;;
encode)
_bw_encode
;;
config)
_bw_config
;;
update)
_bw_update
;;
esac
}
_bw_login() {
_arguments \
"--method[Two-step login method.]" \
"--code[Two-step login code.]" \
{-h,--help}"[output usage information]" \
"*::arg:->args"
}
_bw_logout() {
_arguments \
{-h,--help}"[output usage information]" \
"*::arg:->args"
}
_bw_lock() {
_arguments \
{-h,--help}"[output usage information]" \
"*::arg:->args"
}
_bw_unlock() {
_arguments \
{-h,--help}"[output usage information]" \
"*::arg:->args"
}
_bw_sync() {
_arguments \
{-f,--force}"[Force a full sync.]" \
"--last[Get the last sync date." \
{-h,--help}"[output usage information]" \
"*::arg:->args"
}
_bw_list() {
_arguments \
"--search[Perform a search on the listed objects.]" \
"--url[Filter items of type login with a url-match search.]" \
"--folderid[Filter items by folder id.]" \
"--collectionid[Filter items by collection id.]" \
"--organizationid[Filter items or collections by organization id.]" \
{-h,--help}"[output usage information]" \
"*::arg:->args"
}
_bw_get() {
local -a objects
objects=(
"item"
"username"
"password"
"uri"
"totp"
"exposed"
"attachment"
"folder"
"collection"
"organization"
"template"
"fingerprint"
)
_arguments \
"--itemid[Attachment's item id.]" \
"--output[Output directory or filename for attachment.]" \
{-h,--help}"[output usage information]" \
"1:object:($objects)" \
"2:id:_bw_ids" \
"*::arg:->args"
}
_bw_create() {
_arguments \
"--file[Path to file for attachment.]" \
"--itemid[Attachment's item id.]" \
{-h,--help}"[output usage information]" \
"*::arg:->args"
}
_bw_edit() {
_arguments \
{-h,--help}"[output usage information]" \
"*::arg:->args"
}
_bw_delete() {
_arguments \
"--itemid[Attachment's item id.]" \
{-h,--help}"[output usage information]" \
"*::arg:->args"
}
_bw_share() {
_arguments \
{-h,--help}"[output usage information]" \
"*::arg:->args"
}
_bw_import() {
_arguments \
"--formats[List formats.]" \
{-h,--help}"[output usage information]" \
"*::arg:->args"
}
_bw_export() {
_arguments \
"--output[Output directory or filename.]" \
"--format[Export file format.]" \
{-h,--help}"[output usage information]" \
"*::arg:->args"
}
_bw_generate() {
_arguments \
{-u,--uppercase}"[Include uppercase characters.]" \
{-l,--lowercase}"[Include lowercase characters.]" \
{-n,--number}"[Include numeric characters.]" \
{-s,--special}"[Include special characters.]" \
{-p,--passphrase}"[Generate a passphrase.]" \
"--length[Length of the password.]" \
"--words[Number of words.]" \
"--separator[Word separator.]" \
{-h,--help}"[output usage information]" \
"*::arg:->args"
}
_bw_encode() {
_arguments \
{-h,--help}"[output usage information]" \
"*::arg:->args"
}
_bw_config() {
_arguments \
{-h,--help}"[output usage information]" \
"*::arg:->args"
}
_bw_update() {
_arguments \
{-h,--help}"[output usage information]" \
"*::arg:->args"
}
_bw_ids() {
local -a ids
ids=(${(f)"$(bw list items | jq -r '.[].name' 2>/dev/null)"})
_describe 'id' ids
}
_bw "$@"d