Skip to content

Commit d6a7813

Browse files
Merge pull request #88 from rabbitmq/show-help
Show help when no args provided
2 parents 0dd2c9f + fde118d commit d6a7813

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/cli.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,26 +51,31 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
5151
.infer_subcommands(pre_flight_settings.infer_subcommands)
5252
.infer_long_args(pre_flight_settings.infer_long_options)
5353
.subcommand_value_name("binding")
54+
.arg_required_else_help(true)
5455
.subcommands(binding_subcommands(pre_flight_settings.clone()));
5556
let channels_group = Command::new("channels")
5657
.about("Operations on channels")
5758
.infer_subcommands(pre_flight_settings.infer_subcommands)
5859
.infer_long_args(pre_flight_settings.infer_long_options)
60+
.arg_required_else_help(true)
5961
.subcommands(channels_subcommands(pre_flight_settings.clone()));
6062
let close_group = Command::new("close")
6163
.about("Closes connections")
6264
.infer_subcommands(pre_flight_settings.infer_subcommands)
6365
.infer_long_args(pre_flight_settings.infer_long_options)
66+
.arg_required_else_help(true)
6467
.subcommands(close_subcommands(pre_flight_settings.clone()));
6568
let connections_group = Command::new("connections")
6669
.about("Operations on connections")
6770
.infer_subcommands(pre_flight_settings.infer_subcommands)
6871
.infer_long_args(pre_flight_settings.infer_long_options)
72+
.arg_required_else_help(true)
6973
.subcommands(connections_subcommands(pre_flight_settings.clone()));
7074
let declare_group = Command::new("declare")
7175
.about("Creates or declares objects")
7276
.infer_subcommands(pre_flight_settings.infer_subcommands)
7377
.infer_long_args(pre_flight_settings.infer_long_options)
78+
.arg_required_else_help(true)
7479
.subcommands(declare_subcommands(pre_flight_settings.clone()));
7580
let definitions_group = Command::new("definitions")
7681
.about("Operations on definitions (everything except for messages: virtual hosts, queues, streams, exchanges, bindings, users, etc)")
@@ -81,11 +86,13 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
8186
DEFINITION_GUIDE_URL
8287
))
8388
.subcommand_value_name("export")
89+
.arg_required_else_help(true)
8490
.subcommands(definitions_subcommands(pre_flight_settings.clone()));
8591
let delete_group = Command::new("delete")
8692
.about("Deletes objects")
8793
.infer_subcommands(pre_flight_settings.infer_subcommands)
8894
.infer_long_args(pre_flight_settings.infer_long_options)
95+
.arg_required_else_help(true)
8996
.subcommands(delete_subcommands(pre_flight_settings.clone()));
9097
let deprecated_features_group = Command::new("deprecated_features")
9198
.about("Operations on deprecated features")
@@ -96,12 +103,14 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
96103
DEPRECATED_FEATURE_GUIDE_URL
97104
))
98105
.subcommand_value_name("deprecated feature")
106+
.arg_required_else_help(true)
99107
.subcommands(deprecated_features_subcommands(pre_flight_settings.clone()));
100108
let exchanges_group = Command::new("exchanges")
101109
.about("Operations on exchanges")
102110
.infer_subcommands(pre_flight_settings.infer_subcommands)
103111
.infer_long_args(pre_flight_settings.infer_long_options)
104112
.subcommand_value_name("exchange")
113+
.arg_required_else_help(true)
105114
.subcommands(exchanges_subcommands(pre_flight_settings.clone()));
106115
let export_group = Command::new("export")
107116
.about("See 'definitions export'")
@@ -112,6 +121,7 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
112121
DEFINITION_GUIDE_URL
113122
))
114123
.subcommand_value_name("definitions")
124+
.arg_required_else_help(true)
115125
.subcommands(export_subcommands(pre_flight_settings.clone()));
116126
let feature_flags_group = Command::new("feature_flags")
117127
.about("Operations on feature flags")
@@ -122,6 +132,7 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
122132
FEATURE_FLAG_GUIDE_URL
123133
))
124134
.subcommand_value_name("feature flag")
135+
.arg_required_else_help(true)
125136
.subcommands(feature_flags_subcommands(pre_flight_settings.clone()));
126137
let federation_group = Command::new("federation")
127138
.about("Operations on federation upstreams and links")
@@ -139,13 +150,15 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
139150
FEDERATED_QUEUES_GUIDE_URL,
140151
FEDERATION_REFERENCE_URL
141152
))
153+
.arg_required_else_help(true)
142154
.subcommands(federation_subcommands(pre_flight_settings.clone()));
143155
let get_group = Command::new("get")
144156
.about(color_print::cstr!("Fetches message(s) from a queue or stream via <bold><red>polling</red></bold>. <bold><red>Only suitable for development and test environments</red></bold>."))
145157
.infer_subcommands(pre_flight_settings.infer_subcommands)
146158
.infer_long_args(pre_flight_settings.infer_long_options)
147159
.after_help(color_print::cformat!("<bold>Doc guide</bold>: {}", POLLING_CONSUMER_GUIDE_URL))
148160
.subcommand_value_name("message")
161+
.arg_required_else_help(true)
149162
.subcommands(get_subcommands(pre_flight_settings.clone()));
150163
let global_parameters_group = Command::new("global_parameters")
151164
.about("Operations on global runtime parameters")
@@ -156,12 +169,14 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
156169
RUNTIME_PARAMETER_GUIDE_URL
157170
))
158171
.subcommand_value_name("runtime_parameter")
172+
.arg_required_else_help(true)
159173
.subcommands(global_parameters_subcommands(pre_flight_settings.clone()));
160174
let health_check_group = Command::new("health_check")
161175
.about("Runs health checks")
162176
.infer_subcommands(pre_flight_settings.infer_subcommands)
163177
.infer_long_args(pre_flight_settings.infer_long_options)
164178
.subcommand_value_name("check")
179+
.arg_required_else_help(true)
165180
.subcommands(health_check_subcommands(pre_flight_settings.clone()))
166181
.after_help(color_print::cformat!(
167182
r#"<bold>Doc guides</bold>:
@@ -180,16 +195,19 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
180195
DEFINITION_GUIDE_URL
181196
))
182197
.subcommand_value_name("definitions")
198+
.arg_required_else_help(true)
183199
.subcommands(import_subcommands(pre_flight_settings.clone()));
184200
let list_group = Command::new("list")
185201
.about("Lists objects")
186202
.infer_subcommands(pre_flight_settings.infer_subcommands)
187203
.infer_long_args(pre_flight_settings.infer_long_options)
204+
.arg_required_else_help(true)
188205
.subcommands(list_subcommands(pre_flight_settings.clone()));
189206
let nodes_group = Command::new("nodes")
190207
.about("Node operations")
191208
.infer_subcommands(pre_flight_settings.infer_subcommands)
192209
.infer_long_args(pre_flight_settings.infer_long_options)
210+
.arg_required_else_help(true)
193211
.subcommands(nodes_subcommands(pre_flight_settings.clone()));
194212
let operator_policies_group = Command::new("operator_policies")
195213
.about("Operations on operator policies")
@@ -200,6 +218,7 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
200218
POLICY_GUIDE_URL
201219
))
202220
.subcommand_value_name("operator policy")
221+
.arg_required_else_help(true)
203222
.subcommands(operator_policies_subcommands(pre_flight_settings.clone()));
204223
let parameters_group = Command::new("parameters")
205224
.about("Operations on runtime parameters")
@@ -210,6 +229,7 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
210229
RUNTIME_PARAMETER_GUIDE_URL
211230
))
212231
.subcommand_value_name("runtime_parameter")
232+
.arg_required_else_help(true)
213233
.subcommands(parameters_subcommands(pre_flight_settings.clone()));
214234
let passwords_group = Command::new("passwords")
215235
.about("Operations on passwords")
@@ -219,6 +239,7 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
219239
"<bold>Doc guide</bold>: {}",
220240
PASSWORD_GUIDE_URL
221241
))
242+
.arg_required_else_help(true)
222243
.subcommands(passwords_subcommands(pre_flight_settings.clone()));
223244
let permissions_group = Command::new("permissions")
224245
.about("Operations on user permissions")
@@ -229,6 +250,7 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
229250
ACCESS_CONTROL_GUIDE_URL
230251
))
231252
.subcommand_value_name("permission")
253+
.arg_required_else_help(true)
232254
.subcommands(permissions_subcommands(pre_flight_settings.clone()));
233255
let policies_group = Command::new("policies")
234256
.about("Operations on policies")
@@ -239,25 +261,29 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
239261
POLICY_GUIDE_URL
240262
))
241263
.subcommand_value_name("policy")
264+
.arg_required_else_help(true)
242265
.subcommands(policies_subcommands(pre_flight_settings.clone()));
243266
let publish_group = Command::new("publish")
244267
.about(color_print::cstr!("Publishes (<red>inefficiently</red>) message(s) to a queue or a stream. <bold><red>Only suitable for development and test environments</red></bold>."))
245268
.infer_subcommands(pre_flight_settings.infer_subcommands)
246269
.infer_long_args(pre_flight_settings.infer_long_options)
247270
.after_help(color_print::cformat!("<bold>Doc guide</bold>: {}", PUBLISHER_GUIDE_URL))
248271
.subcommand_value_name("message")
272+
.arg_required_else_help(true)
249273
.subcommands(publish_subcommands(pre_flight_settings.clone()));
250274
let purge_group = Command::new("purge")
251275
.about("Purges queues")
252276
.infer_subcommands(pre_flight_settings.infer_subcommands)
253277
.infer_long_args(pre_flight_settings.infer_long_options)
254278
.subcommand_value_name("queue")
279+
.arg_required_else_help(true)
255280
.subcommands(purge_subcommands(pre_flight_settings.clone()));
256281
let queues_group = Command::new("queues")
257282
.about("Operations on queues")
258283
.infer_subcommands(pre_flight_settings.infer_subcommands)
259284
.infer_long_args(pre_flight_settings.infer_long_options)
260285
.subcommand_value_name("queue")
286+
.arg_required_else_help(true)
261287
.subcommands(queues_subcommands(pre_flight_settings.clone()));
262288
let rebalance_group = Command::new("rebalance")
263289
.about("Rebalancing of leader replicas")
@@ -268,6 +294,7 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
268294
QUORUM_QUEUE_GUIDE_URL
269295
))
270296
.subcommand_value_name("queues")
297+
.arg_required_else_help(true)
271298
.subcommands(rebalance_subcommands(pre_flight_settings.clone()));
272299
let show_group = Command::new("show")
273300
.about("Overview, memory footprint breakdown, and more")
@@ -277,6 +304,7 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
277304
))
278305
.infer_subcommands(pre_flight_settings.infer_subcommands)
279306
.infer_long_args(pre_flight_settings.infer_long_options)
307+
.arg_required_else_help(true)
280308
.subcommands(show_subcommands(pre_flight_settings.clone()));
281309
let shovels_group = Command::new("shovels")
282310
.about("Operations on shovels")
@@ -287,12 +315,14 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
287315
SHOVEL_GUIDE_URL
288316
))
289317
.subcommand_value_name("shovels")
318+
.arg_required_else_help(true)
290319
.subcommands(shovel_subcommands(pre_flight_settings.clone()));
291320
let streams_group = Command::new("streams")
292321
.about("Operations on streams")
293322
.infer_subcommands(pre_flight_settings.infer_subcommands)
294323
.infer_long_args(pre_flight_settings.infer_long_options)
295324
.subcommand_value_name("stream")
325+
.arg_required_else_help(true)
296326
.subcommands(streams_subcommands(pre_flight_settings.clone()));
297327
let tanzu_group = Command::new("tanzu")
298328
.about("Tanzu RabbitMQ-specific commands")
@@ -303,6 +333,7 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
303333
COMMERCIAL_OFFERINGS_GUIDE_URL
304334
))
305335
.subcommand_value_name("subcommand")
336+
.arg_required_else_help(true)
306337
.subcommands(tanzu_subcommands());
307338
let users_group = Command::new("users")
308339
.about("Operations on users")
@@ -313,6 +344,7 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
313344
ACCESS_CONTROL_GUIDE_URL
314345
))
315346
.subcommand_value_name("subcommand")
347+
.arg_required_else_help(true)
316348
.subcommands(users_subcommands(pre_flight_settings.clone()));
317349
let user_limits_group = Command::new("user_limits")
318350
.about("Operations on per-user (resource) limits")
@@ -323,11 +355,13 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
323355
USER_LIMIT_GUIDE_URL
324356
))
325357
.subcommand_value_name("user_limit")
358+
.arg_required_else_help(true)
326359
.subcommands(user_limits_subcommands(pre_flight_settings.clone()));
327360
let vhosts_group = Command::new("vhosts")
328361
.about("Virtual host operations")
329362
.infer_subcommands(pre_flight_settings.infer_subcommands)
330363
.infer_long_args(pre_flight_settings.infer_long_options)
364+
.arg_required_else_help(true)
331365
.subcommands(vhosts_subcommands(pre_flight_settings.clone()));
332366
let vhost_limits_group = Command::new("vhost_limits")
333367
.about("Operations on virtual host (resource) limits")
@@ -338,6 +372,7 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
338372
VIRTUAL_HOST_LIMIT_GUIDE_URL
339373
))
340374
.subcommand_value_name("vhost_limit")
375+
.arg_required_else_help(true)
341376
.subcommands(vhost_limits_subcommands(pre_flight_settings.clone()));
342377

343378
let command_groups = [

0 commit comments

Comments
 (0)