-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.rs
314 lines (313 loc) · 13.5 KB
/
cli.rs
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
use clap::{App, AppSettings, Arg, ArgGroup, SubCommand};
pub fn build_cli() -> App<'static, 'static> {
App::new(crate_name!())
.about(crate_description!())
.author(crate_authors!(", "))
.version(crate_version!())
.arg(Arg::with_name("credentials")
.short("c")
.long("creds")
.long("credentials")
.takes_value(true)
.help("A JSON file containing service credentials. Default is \
the value of the environment variable \
WDSCLI_CREDENTIALS_FILE or 'credentials.json' when \
WDSCLI_CREDENTIALS_FILE is not set."))
.setting(AppSettings::SubcommandRequired)
.subcommand(SubCommand::with_name("generate-completions")
.about("Generate a shell command completion script.")
.arg(Arg::with_name("shell")
.required(true)
.help("Which shell to generate completions for. One of: \
bash, fish, powershell or zsh")))
.subcommand(SubCommand::with_name("crawler-configuration")
.visible_alias("cc")
.about("Print out crawler configuration.")
.arg(Arg::with_name("newest")
.short("n")
.long("newest")
.help("Use most recently created collection, default if no \
other selection is made"))
.arg(Arg::with_name("oldest")
.short("o")
.long("oldest")
.help("Use the collection created the longest time ago"))
.arg(Arg::with_name("name")
.short("m")
.long("named")
.takes_value(true)
.help("Use the collection with a name matching this"))
.arg(Arg::with_name("id")
.short("i")
.long("with-id")
.takes_value(true)
.help("Use the collection with this id"))
.group(ArgGroup::with_name("selector")
.args(&["newest", "oldest", "name", "id"])))
.subcommand(SubCommand::with_name("create-collection")
.visible_alias("cl")
.about("Create a new collection using the most recently created \
configuration")
.arg(Arg::with_name("name")
.required(true)
.help("The name of the collection."))
.arg(Arg::with_name("description")
.short("d")
.long("desc")
.long("description")
.takes_value(true)
.help("Description text for the collection.")))
.subcommand(SubCommand::with_name("create-configuration")
.visible_alias("cn")
.about("Create a new configuration.")
.arg(Arg::with_name("configuration")
.required(true)
.help("File containing the configuration JSON.")))
.subcommand(SubCommand::with_name("create-environment")
.visible_alias("ce")
.about("Create a writable environment")
.arg(Arg::with_name("name")
.required(true)
.help("The name of the environment."))
.arg(Arg::with_name("size")
.short("s")
.long("size")
.takes_value(true)
.help("The size environment to create."))
.arg(Arg::with_name("description")
.short("d")
.long("desc")
.long("description")
.takes_value(true)
.help("Description text for the environment."))
.arg(Arg::with_name("wait")
.long("wait")
.help("Wait for the new environment to become active.")))
.subcommand(SubCommand::with_name("delete-collection")
.visible_alias("dl")
.about("Delete a collection.")
.arg(Arg::with_name("all")
.long("all")
.help("Delete all existing collections"))
.arg(Arg::with_name("newest")
.short("n")
.long("newest")
.help("Delete the most recently created collection"))
.arg(Arg::with_name("oldest")
.short("o")
.long("oldest")
.help("Delete the collection created the longest time ago"))
.arg(Arg::with_name("name")
.short("m")
.long("named")
.takes_value(true)
.help("Delete the collection with a name matching this"))
.arg(Arg::with_name("id")
.short("i")
.long("with-id")
.takes_value(true)
.help("Delete the collection with this id"))
.group(ArgGroup::with_name("selector")
.required(true)
.args(&["all", "newest", "oldest", "name", "id"])))
.subcommand(SubCommand::with_name("delete-configuration")
.visible_alias("dl")
.about("Delete a configuration.")
.arg(Arg::with_name("newest")
.short("n")
.long("newest")
.help("Delete the most recently created configuration"))
.arg(Arg::with_name("name")
.short("m")
.long("named")
.takes_value(true)
.help("Delete the configuration with a name matching this"))
.arg(Arg::with_name("id")
.short("i")
.long("with-id")
.takes_value(true)
.help("Delete the configuration with this id"))
.group(ArgGroup::with_name("selector")
.required(true)
.args(&["all", "newest", "oldest", "name", "id"])))
.subcommand(SubCommand::with_name("delete-environment")
.visible_alias("de")
.about("Delete the writable environment"))
.subcommand(SubCommand::with_name("overview")
.visible_alias("o")
.about("Displays information about existing resources.")
.arg(Arg::with_name("guid")
.short("g")
.long("guid")
.help("Display the GUID for each item")))
.subcommand(SubCommand::with_name("query")
.visible_alias("q")
.about("Query a collection.")
.arg(Arg::with_name("aggregation")
.short("a")
.long("aggregation")
.takes_value(true)
.help("The aggregation string for the query"))
.arg(Arg::with_name("count")
.short("C")
.long("count")
.takes_value(true)
.help("The number of results to return for the query"))
.arg(Arg::with_name("offset")
.long("offset")
.takes_value(true)
.help("The offset of the first result returned by the query"))
.arg(Arg::with_name("filter")
.short("f")
.long("filter")
.takes_value(true)
.help("The filter string for the query"))
.arg(Arg::with_name("query")
.short("q")
.long("query")
.takes_value(true)
.help("The query string for the query"))
.arg(Arg::with_name("return_hierarchy")
.short("r")
.long("return_hierarchy")
.takes_value(true)
.help("The return hierarchy string for the query"))
.arg(Arg::with_name("newest")
.short("n")
.long("newest")
.help("Use most recently created collection, default if no \
other selection is made"))
.arg(Arg::with_name("oldest")
.short("o")
.long("oldest")
.help("Use the collection created the longest time ago"))
.arg(Arg::with_name("name")
.short("m")
.long("named")
.takes_value(true)
.help("Use the collection with a name matching this"))
.arg(Arg::with_name("id")
.short("i")
.long("with-id")
.takes_value(true)
.help("Use the collection with this id"))
.group(ArgGroup::with_name("selector")
.args(&["newest", "oldest", "name", "id"])))
.subcommand(SubCommand::with_name("show-environment")
.visible_alias("se")
.about("Displays detailed information about an environment.")
.arg(Arg::with_name("read-only")
.long("read-only")
.short("r")
.help("Show the read only environment"))
.arg(Arg::with_name("writable")
.long("writable")
.short("w")
.help("Show the writable environment"))
.group(ArgGroup::with_name("selector")
.args(&["read-only", "writable"])))
.subcommand(SubCommand::with_name("show-collection")
.visible_alias("sl")
.about("Displays detailed information about a collection.")
.arg(Arg::with_name("newest")
.short("n")
.long("newest")
.help("Use most recently created collection, default if no \
other selection is made"))
.arg(Arg::with_name("oldest")
.short("o")
.long("oldest")
.help("Use the collection created the longest time ago"))
.arg(Arg::with_name("name")
.short("m")
.long("named")
.takes_value(true)
.help("Use the collection with a name matching this"))
.arg(Arg::with_name("id")
.short("i")
.long("with-id")
.takes_value(true)
.help("Use the collection with this id"))
.group(ArgGroup::with_name("selector")
.args(&["newest", "oldest", "name", "id"])))
.subcommand(SubCommand::with_name("show-document")
.visible_alias("sd")
.about("Displays status information about a document.")
.arg(Arg::with_name("document_id")
.required(true)
.multiple(true)
.help("The document_id(s) to lookup."))
.arg(Arg::with_name("newest")
.short("n")
.long("newest")
.help("Use most recently created collection, default if no \
other selection is made"))
.arg(Arg::with_name("oldest")
.short("o")
.long("oldest")
.help("Use the collection created the longest time ago"))
.arg(Arg::with_name("name")
.short("m")
.long("named")
.takes_value(true)
.help("Use the collection with a name matching this"))
.arg(Arg::with_name("id")
.short("i")
.long("with-id")
.takes_value(true)
.help("Use the collection with this id"))
.group(ArgGroup::with_name("selector")
.args(&["newest", "oldest", "name", "id"])))
.subcommand(SubCommand::with_name("add-document")
.visible_alias("ad")
.about("Add a document to a collection.")
.arg(Arg::with_name("filenames")
.required(true)
.multiple(true)
.help("File paths for documents to add."))
.arg(Arg::with_name("newest")
.short("n")
.long("newest")
.help("Use most recently created collection, default if no \
other selection is made"))
.arg(Arg::with_name("oldest")
.short("o")
.long("oldest")
.help("Use the collection created the longest time ago"))
.arg(Arg::with_name("name")
.short("m")
.long("named")
.takes_value(true)
.help("Use the collection with a name matching this"))
.arg(Arg::with_name("id")
.short("i")
.long("with-id")
.takes_value(true)
.help("Use the collection with this id"))
.group(ArgGroup::with_name("selector")
.args(&["newest", "oldest", "name", "id"])))
.subcommand(SubCommand::with_name("show-configuration")
.visible_alias("sn")
.about("Displays detailed information about a configuration.")
.arg(Arg::with_name("newest")
.short("n")
.long("newest")
.help("Use most recently created configuration, default if \
no other selection is made"))
.arg(Arg::with_name("oldest")
.short("o")
.long("oldest")
.help("Use the configuration created the longest time ago"))
.arg(Arg::with_name("name")
.short("m")
.long("named")
.takes_value(true)
.help("Use the configuration with a name matching this"))
.arg(Arg::with_name("id")
.short("i")
.long("with-id")
.takes_value(true)
.help("Use the configuration with this id"))
.group(ArgGroup::with_name("selector")
.args(&["newest", "oldest", "name", "id"])))
}