@@ -349,6 +349,8 @@ async fn handle_comment(
349
349
ctx : Arc < BorsContext > ,
350
350
comment : PullRequestComment ,
351
351
) -> anyhow:: Result < ( ) > {
352
+ use std:: fmt:: Write ;
353
+
352
354
let pr_number = comment. pr_number ;
353
355
let commands = ctx. parser . parse_commands ( & comment. text ) ;
354
356
@@ -488,7 +490,7 @@ async fn handle_comment(
488
490
}
489
491
}
490
492
Err ( error) => {
491
- let message = match error {
493
+ let mut message = match error {
492
494
CommandParseError :: MissingCommand => "Missing command." . to_string ( ) ,
493
495
CommandParseError :: UnknownCommand ( command) => {
494
496
format ! ( r#"Unknown command "{command}"."# )
@@ -503,9 +505,14 @@ async fn handle_comment(
503
505
format ! ( r#"Argument "{arg}" found multiple times."# )
504
506
}
505
507
CommandParseError :: ValidationError ( error) => {
506
- format ! ( "Invalid command: {error}" )
508
+ format ! ( "Invalid command: {error}. " )
507
509
}
508
510
} ;
511
+ writeln ! (
512
+ message,
513
+ " Run `{} help` to see available commands." ,
514
+ ctx. parser. prefix( )
515
+ ) ?;
509
516
tracing:: warn!( "{}" , message) ;
510
517
repo. client
511
518
. post_comment ( pr_github. number , Comment :: new ( message) )
@@ -631,4 +638,14 @@ mod tests {
631
638
} )
632
639
. await ;
633
640
}
641
+
642
+ #[ sqlx:: test]
643
+ async fn unknown_command ( pool : sqlx:: PgPool ) {
644
+ run_test ( pool, |mut tester| async {
645
+ tester. post_comment ( Comment :: from ( "@bors foo" ) ) . await ?;
646
+ insta:: assert_snapshot!( tester. get_comment( ) . await ?, @r#"Unknown command "foo". Run `@bors help` to see available commands."# ) ;
647
+ Ok ( tester)
648
+ } )
649
+ . await ;
650
+ }
634
651
}
0 commit comments