Skip to content

Commit 15ab2ae

Browse files
New command group: parameters
Closes #59
1 parent bffdc27 commit 15ab2ae

File tree

4 files changed

+403
-262
lines changed

4 files changed

+403
-262
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Enhancements
66

77
* `nodes` is a new command group for operations on nodes
8+
* `parameters` is a new command group for operations on [runtime parameters](https://www.rabbitmq.com/docs/parameters)
89
* `users` is a new command group for operations on users
910
* `vhosts` is a new command group for operations on virtual hosts
1011
* Command groups are now ordered alphabetically

src/cli.rs

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,24 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
158158
.infer_subcommands(pre_flight_settings.infer_subcommands)
159159
.infer_long_args(pre_flight_settings.infer_long_options)
160160
.subcommands(nodes_subcommands(pre_flight_settings.clone()));
161+
let parameters_group = Command::new("parameters")
162+
.about("Operations on runtime parameters")
163+
.infer_subcommands(pre_flight_settings.infer_subcommands)
164+
.infer_long_args(pre_flight_settings.infer_long_options)
165+
.after_help(color_print::cformat!(
166+
"<bold>Doc guide</bold>: {}",
167+
RUNTIME_PARAMETER_GUIDE_URL
168+
))
169+
.subcommand_value_name("runtime_parameter")
170+
.subcommands(parameters_subcommands(pre_flight_settings.clone()));
161171
let policies_group = Command::new("policies")
162172
.about("Operations on policies")
163173
.infer_subcommands(pre_flight_settings.infer_subcommands)
164174
.infer_long_args(pre_flight_settings.infer_long_options)
175+
.after_help(color_print::cformat!(
176+
"<bold>Doc guide</bold>: {}",
177+
POLICY_GUIDE_URL
178+
))
165179
.subcommand_value_name("policy")
166180
.subcommands(policies_subcommands(pre_flight_settings.clone()));
167181
let publish_group = Command::new("publish")
@@ -246,6 +260,7 @@ pub fn parser(pre_flight_settings: PreFlightSettings) -> Command {
246260
import_group,
247261
list_group,
248262
nodes_group,
263+
parameters_group,
249264
policies_group,
250265
publish_group,
251266
purge_group,
@@ -1201,6 +1216,66 @@ fn purge_subcommands(pre_flight_settings: PreFlightSettings) -> [Command; 1] {
12011216
[queue_cmd].map(|cmd| cmd.infer_long_args(pre_flight_settings.infer_long_options))
12021217
}
12031218

1219+
fn parameters_subcommands(pre_flight_settings: PreFlightSettings) -> [Command; 3] {
1220+
let list_cmd = Command::new("list")
1221+
.arg(
1222+
Arg::new("component")
1223+
.long("component")
1224+
.help("component (for example: federation-upstream, vhost-limits)")
1225+
.required(false),
1226+
)
1227+
.long_about("Lists runtime parameters")
1228+
.after_help(color_print::cformat!(
1229+
"<bold>Doc guide</bold>: {}",
1230+
RUNTIME_PARAMETER_GUIDE_URL
1231+
));
1232+
1233+
let set_cmd = Command::new("set")
1234+
.alias("declare")
1235+
.about("Sets a runtime parameter")
1236+
.after_help(color_print::cformat!(
1237+
"<bold>Doc guide:</bold>: {}",
1238+
RUNTIME_PARAMETER_GUIDE_URL
1239+
))
1240+
.arg(
1241+
Arg::new("name")
1242+
.long("name")
1243+
.help("parameter's name")
1244+
.required(true),
1245+
)
1246+
.arg(
1247+
Arg::new("component")
1248+
.long("component")
1249+
.help("component (eg. federation)")
1250+
.required(true),
1251+
)
1252+
.arg(
1253+
Arg::new("value")
1254+
.long("value")
1255+
.help("parameter's value")
1256+
.required(true),
1257+
);
1258+
1259+
let clear_cmd = Command::new("clear")
1260+
.alias("delete")
1261+
.about("Clears (deletes) a runtime parameter")
1262+
.arg(
1263+
Arg::new("name")
1264+
.long("name")
1265+
.help("parameter's name")
1266+
.required(true),
1267+
)
1268+
.arg(
1269+
Arg::new("component")
1270+
.long("component")
1271+
.help("component (eg. federation-upstream)")
1272+
.required(true),
1273+
);
1274+
1275+
[clear_cmd, list_cmd, set_cmd]
1276+
.map(|cmd| cmd.infer_long_args(pre_flight_settings.infer_long_options))
1277+
}
1278+
12041279
fn policies_subcommands(pre_flight_settings: PreFlightSettings) -> [Command; 5] {
12051280
let declare_cmd = Command::new("declare")
12061281
.about("Creates or updates a policy")
@@ -1280,8 +1355,8 @@ fn policies_subcommands(pre_flight_settings: PreFlightSettings) -> [Command; 5]
12801355

12811356
[
12821357
declare_cmd,
1283-
list_cmd,
12841358
delete_cmd,
1359+
list_cmd,
12851360
list_in_cmd,
12861361
list_matching_cmd,
12871362
]

0 commit comments

Comments
 (0)