Skip to content

Commit fa857ef

Browse files
committed
Auto merge of #698 - lqd:cancel_equals_abort, r=Mark-Simulacrum
cancel = abort This PR allows patterns to be used in the webhooks command parser, for the sole purpose of accepting `cancel` as an alias to `abort`. <sub>(this is for `@compiler-errors)</sub>`
2 parents 48c666a + ff92dc1 commit fa857ef

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cli.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ impl Crater {
521521
} else {
522522
default_capabilities_for_target()
523523
};
524-
caps.extend(capabilities.clone().into_iter());
524+
caps.extend(capabilities.clone());
525525

526526
agent::run(
527527
url,

src/server/routes/webhooks/args.rs

+13-6
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ pub enum CommandParseError {
1717

1818
macro_rules! generate_parser {
1919
(pub enum $enum:ident {
20-
$($command:expr => $variant:ident($var_struct:ident {
20+
$($command:pat => $variant:ident($var_struct:ident {
2121
$($flag:ident: $type:ty = $name:expr,)*
2222
}))*
23-
_ => $d_variant:ident($d_var_struct:ident {$($d_flag:ident: $d_type:ty = $d_name:expr,)*})
23+
=> $d_variant:ident($d_var_struct:ident {$($d_flag:ident: $d_type:ty = $d_name:expr,)*})
2424
}) => {
2525
use crate::prelude::*;
2626
use std::str::FromStr;
@@ -128,7 +128,7 @@ generate_parser!(pub enum Command {
128128
requirement: Option<String> = "requirement",
129129
})
130130

131-
"abort" => Abort(AbortArgs {
131+
"abort" | "cancel" => Abort(AbortArgs {
132132
name: Option<String> = "name",
133133
})
134134

@@ -144,7 +144,7 @@ generate_parser!(pub enum Command {
144144

145145
"reload-acl" => ReloadACL(ReloadACLArgs {})
146146

147-
_ => Edit(EditArgs {
147+
=> Edit(EditArgs {
148148
name: Option<String> = "name",
149149
start: Option<Toolchain> = "start",
150150
end: Option<Toolchain> = "end",
@@ -169,11 +169,11 @@ mod tests {
169169
arg2: Option<String> = "arg2",
170170
})
171171

172-
"bar" => Bar(BarArgs {
172+
"bar" | "bar-alias" => Bar(BarArgs {
173173
arg3: Option<String> = "arg3",
174174
})
175175

176-
_ => Baz(BazArgs {
176+
=> Baz(BazArgs {
177177
arg4: Option<i32> = "arg4",
178178
})
179179
});
@@ -201,6 +201,7 @@ mod tests {
201201
})
202202
);
203203
test!("bar", TestCommand::Bar(BarArgs { arg3: None }));
204+
test!("bar-alias", TestCommand::Bar(BarArgs { arg3: None }));
204205
test!("", TestCommand::Baz(BazArgs { arg4: None }));
205206

206207
// Test if args are parsed correctly
@@ -230,6 +231,12 @@ mod tests {
230231
arg3: Some("foo \" bar".into()),
231232
})
232233
);
234+
test!(
235+
"bar-alias arg3=\"foo \\\" bar\"",
236+
TestCommand::Bar(BarArgs {
237+
arg3: Some("foo \" bar".into()),
238+
})
239+
);
233240
test!("arg4=42", TestCommand::Baz(BazArgs { arg4: Some(42) }));
234241

235242
// Test if invalid args are rejected

0 commit comments

Comments
 (0)