Skip to content

Commit 901340e

Browse files
Make it possible to specify a few global options --at-the-end
This generation of 'rabbitmqadmin' strictly separates global options from the command-specific ones. This has both pros and cons. Specifying a few very common options, namely --vhost, at the end of the argument list, was common with 'rabbitmqadmin' v1. Clap allows a global option to be marked as such, which means it will still be correctly parsed even when given amongst the command-specific ones. This has a serious downside, too: if a subcommand declares an option with the same ID, long or short name, the parser will panic. Therefore this commit cherry picks a few options that are truly global and unlikely will run into conflicts: * --vhost * TLS-related options * --quiet/-q The docs will continue saying that all global options must be passed before the subcommands because that's still true for the majority of them.
1 parent db4fef7 commit 901340e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/cli.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
118118
Arg::new("vhost")
119119
.short('V')
120120
.long("vhost")
121+
.global(true)
121122
.env("RABBITMQADMIN_TARGET_VHOST")
122123
.help("target virtual host. Defaults to '/'"),
123124
)
@@ -155,6 +156,7 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
155156
.arg(
156157
Arg::new("tls")
157158
.long("use-tls")
159+
.global(true)
158160
.help("use TLS (HTTPS) for HTTP API requests ")
159161
.env("RABBITMQADMIN_USE_TLS")
160162
.value_parser(value_parser!(bool))
@@ -165,6 +167,7 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
165167
.arg(
166168
Arg::new("tls-ca-cert-file")
167169
.long("tls-ca-cert-file")
170+
.global(true)
168171
.required(false)
169172
.requires("tls")
170173
.help("Local path to a CA certificate file in the PEM format")
@@ -174,6 +177,7 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
174177
.arg(
175178
Arg::new("tls-cert-file")
176179
.long("tls-cert-file")
180+
.global(true)
177181
.required(false)
178182
.requires("tls-key-file")
179183
.help("Local path to a client certificate file in the PEM format")
@@ -183,6 +187,7 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
183187
.arg(
184188
Arg::new("tls-key-file")
185189
.long("tls-key-file")
190+
.global(true)
186191
.required(false)
187192
.requires("tls-cert-file")
188193
.help("Local path to a client private key file in the PEM format")
@@ -203,6 +208,7 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
203208
.arg(
204209
Arg::new("non_interactive")
205210
.long("non-interactive")
211+
.global(true)
206212
.env("RABBITMQADMIN_NON_INTERACTIVE_MODE")
207213
.help("pass when invoking from scripts")
208214
.conflicts_with("table_style")
@@ -214,6 +220,7 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
214220
.arg(
215221
Arg::new("table_style")
216222
.long("table-style")
223+
.global(true)
217224
.env("RABBITMQADMIN_TABLE_STYLE")
218225
.help("style preset to apply to output tables: modern, borderless, ascii, dots, psql, markdown, sharp")
219226
.conflicts_with("non_interactive")

0 commit comments

Comments
 (0)