Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions crates/cli/src/commands/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ Examples:
rc event add local/my-bucket arn:aws:sns:us-east-1:123456789012:alerts --event delete
rc bucket event add local/my-bucket arn:aws:lambda:us-east-1:123456789012:function:thumbnail --event put,delete";

const EVENT_REMOVE_AFTER_HELP: &str = "\
Examples:
rc bucket event remove local/my-bucket arn:aws:sqs:us-east-1:123456789012:jobs
rc event remove local/my-bucket arn:aws:sns:us-east-1:123456789012:alerts";

/// Manage bucket event notifications
#[derive(Args, Debug)]
#[command(after_help = EVENT_AFTER_HELP)]
Expand Down Expand Up @@ -71,6 +76,7 @@ pub struct AddArgs {
}

#[derive(Args, Debug)]
#[command(after_help = EVENT_REMOVE_AFTER_HELP)]
pub struct RemoveArgs {
/// Path to the bucket (alias/bucket)
pub path: String,
Expand Down
24 changes: 24 additions & 0 deletions crates/cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,4 +472,28 @@ mod tests {
other => panic!("expected bucket command, got {:?}", other),
}
}

#[test]
fn cli_accepts_bucket_event_remove_subcommand() {
let cli = Cli::try_parse_from([
"rc",
"bucket",
"event",
"remove",
"local/my-bucket",
"arn:aws:sns:us-east-1:123456789012:alerts",
])
.expect("parse bucket event remove");

match cli.command {
Commands::Bucket(args) => match args.command {
bucket::BucketCommands::Event(event::EventCommands::Remove(arg)) => {
assert_eq!(arg.path, "local/my-bucket");
assert_eq!(arg.arn, "arn:aws:sns:us-east-1:123456789012:alerts");
}
other => panic!("expected bucket event remove command, got {:?}", other),
},
other => panic!("expected bucket command, got {:?}", other),
}
}
}
18 changes: 18 additions & 0 deletions crates/cli/tests/help_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,15 @@ fn nested_subcommand_help_contract() {
"rc bucket event add local/my-bucket arn:aws:sqs:us-east-1:123456789012:jobs --event put",
],
},
HelpCase {
args: &["bucket", "event", "remove"],
usage: "Usage: rc bucket event remove [OPTIONS] <PATH> <ARN>",
expected_tokens: &[
"--force",
"Examples:",
"rc event remove local/my-bucket arn:aws:sns:us-east-1:123456789012:alerts",
],
},
HelpCase {
args: &["object", "copy"],
usage: "Usage: rc object copy [OPTIONS] <SOURCE> <TARGET>",
Expand Down Expand Up @@ -733,6 +742,15 @@ fn nested_subcommand_help_contract() {
"rc event add local/my-bucket arn:aws:sns:us-east-1:123456789012:alerts --event delete",
],
},
HelpCase {
args: &["event", "remove"],
usage: "Usage: rc event remove [OPTIONS] <PATH> <ARN>",
expected_tokens: &[
"--force",
"Examples:",
"rc event remove local/my-bucket arn:aws:sns:us-east-1:123456789012:alerts",
],
},
HelpCase {
args: &["replicate", "list"],
usage: "Usage: rc replicate list [OPTIONS] <PATH>",
Expand Down