Skip to content

Commit fcd964f

Browse files
Introduce 'shovels list'
for listing only the shovels in a particular virtual host.
1 parent 3140fb4 commit fcd964f

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed

src/cli.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2861,14 +2861,21 @@ pub fn get_subcommands(pre_flight_settings: PreFlightSettings) -> [Command; 1] {
28612861
)].map(|cmd| cmd.infer_long_args(pre_flight_settings.infer_long_options))
28622862
}
28632863

2864-
pub fn shovel_subcommands(pre_flight_settings: PreFlightSettings) -> [Command; 4] {
2864+
pub fn shovel_subcommands(pre_flight_settings: PreFlightSettings) -> [Command; 5] {
28652865
let list_all_cmd = Command::new("list_all")
28662866
.long_about("Lists shovels in all virtual hosts")
28672867
.after_help(color_print::cformat!(
28682868
"<bold>Doc guide</bold>: {}",
28692869
SHOVEL_GUIDE_URL
28702870
));
28712871

2872+
let list_cmd = Command::new("list")
2873+
.long_about("Lists shovels in a specific virtual host")
2874+
.after_help(color_print::cformat!(
2875+
"<bold>Doc guide</bold>: {}",
2876+
SHOVEL_GUIDE_URL
2877+
));
2878+
28722879
let declare_091_cmd = Command::new("declare_amqp091")
28732880
.long_about(
28742881
"Declares a dynamic shovel that uses AMQP 0-9-1 for both source and destination",
@@ -3003,8 +3010,14 @@ pub fn shovel_subcommands(pre_flight_settings: PreFlightSettings) -> [Command; 4
30033010
.required(true),
30043011
);
30053012

3006-
[list_all_cmd, declare_091_cmd, declare_10_cmd, delete_cmd]
3007-
.map(|cmd| cmd.infer_long_args(pre_flight_settings.infer_long_options))
3013+
[
3014+
list_all_cmd,
3015+
list_cmd,
3016+
declare_091_cmd,
3017+
declare_10_cmd,
3018+
delete_cmd,
3019+
]
3020+
.map(|cmd| cmd.infer_long_args(pre_flight_settings.infer_long_options))
30083021
}
30093022

30103023
fn federation_subcommands(pre_flight_settings: PreFlightSettings) -> [Command; 6] {

src/commands.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,10 @@ pub fn list_shovels(client: APIClient) -> ClientResult<Vec<responses::Shovel>> {
248248
client.list_shovels()
249249
}
250250

251+
pub fn list_shovels_in(client: APIClient, vhost: &str) -> ClientResult<Vec<responses::Shovel>> {
252+
client.list_shovels_in(vhost)
253+
}
254+
251255
pub fn declare_amqp10_shovel(
252256
client: APIClient,
253257
vhost: &str,

src/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,10 @@ fn dispatch_common_subcommand(
10351035
let result = commands::list_shovels(client);
10361036
res_handler.tabular_result(result)
10371037
}
1038+
("shovels", "list") => {
1039+
let result = commands::list_shovels_in(client, &vhost);
1040+
res_handler.tabular_result(result)
1041+
}
10381042
("streams", "declare") => {
10391043
let result = commands::declare_stream(client, &vhost, second_level_args);
10401044
res_handler.no_output_on_success(result);

tests/shovel_tests.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
mod test_helpers;
1616

1717
use crate::test_helpers::*;
18+
use predicates::boolean::PredicateBooleanExt;
1819
use predicates::prelude::predicate;
1920

2021
#[test]
@@ -150,6 +151,23 @@ fn test_amqp091_shovel_declaration_and_deletion() -> Result<(), Box<dyn std::err
150151
dest_x,
151152
]);
152153

154+
run_succeeds(["-V", vh, "shovels", "list"]).stdout(
155+
predicate::str::contains(vh)
156+
.and(predicate::str::contains(src_q))
157+
.and(predicate::str::contains("dynamic"))
158+
.and(predicate::str::contains("node"))
159+
.and(predicate::str::contains("state")),
160+
);
161+
162+
run_succeeds(["-V", vh, "shovels", "list_all"]).stdout(
163+
predicate::str::contains(vh)
164+
.and(predicate::str::contains(src_q))
165+
.and(predicate::str::contains("dynamic"))
166+
.and(predicate::str::contains("vhost"))
167+
.and(predicate::str::contains("node"))
168+
.and(predicate::str::contains("state")),
169+
);
170+
153171
run_succeeds(["-V", vh, "shovels", "delete", "--name", name]);
154172
run_succeeds(["-V", vh, "shovels", "delete", "--name", name]);
155173

0 commit comments

Comments
 (0)