File tree 2 files changed +24
-3
lines changed
2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -118,14 +118,14 @@ fn execute(flags: Flags, config: &Config) -> CliResult<Option<()>> {
118
118
// message for `cargo help`
119
119
"help" if flags. arg_args [ 0 ] == "-h" ||
120
120
flags. arg_args [ 0 ] == "--help" => {
121
- vec ! [ "cargo" . to_string( ) , "help" . to_string( ) , "help " . to_string( ) ]
121
+ vec ! [ "cargo" . to_string( ) , "help" . to_string( ) , "-h " . to_string( ) ]
122
122
}
123
123
124
124
// For `cargo help foo`, print out the usage message for the specified
125
125
// subcommand by executing the command with the `-h` flag.
126
126
"help" => {
127
- vec ! [ "cargo" . to_string( ) , "help" . to_string ( ) ,
128
- flags . arg_args [ 0 ] . clone ( ) ]
127
+ vec ! [ "cargo" . to_string( ) , flags . arg_args [ 0 ] . clone ( ) ,
128
+ "-h" . to_string ( ) ]
129
129
}
130
130
131
131
// For all other invocations, we're of the form `cargo foo args...`. We
Original file line number Diff line number Diff line change @@ -105,3 +105,24 @@ test!(override_cargo_home {
105
105
File :: open( & toml) . unwrap( ) . read_to_string( & mut contents) . unwrap( ) ;
106
106
assert!( contents. contains( r#"authors = ["foo <bar>"]"# ) ) ;
107
107
} ) ;
108
+
109
+ test ! ( cargo_help {
110
+ assert_that( process( & cargo_dir( ) . join( "cargo" ) ) . unwrap( ) ,
111
+ execs( ) . with_status( 0 ) ) ;
112
+ assert_that( process( & cargo_dir( ) . join( "cargo" ) ) . unwrap( ) . arg( "help" ) ,
113
+ execs( ) . with_status( 0 ) ) ;
114
+ assert_that( process( & cargo_dir( ) . join( "cargo" ) ) . unwrap( ) . arg( "-h" ) ,
115
+ execs( ) . with_status( 0 ) ) ;
116
+ assert_that( process( & cargo_dir( ) . join( "cargo" ) ) . unwrap( )
117
+ . arg( "help" ) . arg( "build" ) ,
118
+ execs( ) . with_status( 0 ) ) ;
119
+ assert_that( process( & cargo_dir( ) . join( "cargo" ) ) . unwrap( )
120
+ . arg( "build" ) . arg( "-h" ) ,
121
+ execs( ) . with_status( 0 ) ) ;
122
+ assert_that( process( & cargo_dir( ) . join( "cargo" ) ) . unwrap( )
123
+ . arg( "help" ) . arg( "-h" ) ,
124
+ execs( ) . with_status( 0 ) ) ;
125
+ assert_that( process( & cargo_dir( ) . join( "cargo" ) ) . unwrap( )
126
+ . arg( "help" ) . arg( "help" ) ,
127
+ execs( ) . with_status( 0 ) ) ;
128
+ } ) ;
You can’t perform that action at this time.
0 commit comments