File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change 11use std:: ffi:: OsString ;
2+ use std:: fmt:: Write as _;
23use std:: iter;
34use std:: path:: Path ;
45
@@ -69,10 +70,20 @@ pub fn run(
6970 names. join( ", " )
7071 )
7172 } else {
72- anyhow:: bail!(
73- "`cargo run` can run at most one executable, but \
73+ let mut message = "`cargo run` can run at most one executable, but \
7474 multiple were specified"
75- )
75+ . to_owned ( ) ;
76+ write ! ( & mut message, "\n help: available targets:" ) ?;
77+ for ( pkg, bin) in & bins {
78+ write ! (
79+ & mut message,
80+ "\n {} `{}` in package `{}`" ,
81+ bin. kind( ) . description( ) ,
82+ bin. name( ) ,
83+ pkg. name( )
84+ ) ?;
85+ }
86+ anyhow:: bail!( message)
7687 }
7788 }
7889
Original file line number Diff line number Diff line change @@ -836,6 +836,11 @@ fn ambiguous_bin_name() {
836836 . with_status ( 101 )
837837 . with_stderr_data ( str![ [ r#"
838838[ERROR] `cargo run` can run at most one executable, but multiple were specified
839+ [HELP] available targets:
840+ bin `ambiguous` in package `crate1`
841+ bin `ambiguous` in package `crate2`
842+ bin `ambiguous` in package `crate3`
843+ bin `ambiguous` in package `crate4`
839844
840845"# ] ] )
841846 . run ( ) ;
@@ -1014,6 +1019,9 @@ fn either_name_or_example() {
10141019 . with_status ( 101 )
10151020 . with_stderr_data ( str![ [ r#"
10161021[ERROR] `cargo run` can run at most one executable, but multiple were specified
1022+ [HELP] available targets:
1023+ bin `a` in package `foo`
1024+ example `b` in package `foo`
10171025
10181026"# ] ] )
10191027 . run ( ) ;
You can’t perform that action at this time.
0 commit comments