@@ -431,7 +431,7 @@ impl<'a, 'v, 'ab, 'u, 'ar> App<'a, 'v, 'ab, 'u, 'ar>{
431
431
format!( "-{}=" , o. long. unwrap( ) )
432
432
} , o. name) ) ;
433
433
434
- print ! ( "\t {} {} {} {} {}" , if let Some ( ref name ) = self . bin_name { name . replace ( "-" , " " ) } else { self . name. clone( ) } ,
434
+ print ! ( "\t {} {} {} {} {}" , self . bin_name. clone ( ) . unwrap_or ( self . name. clone( ) ) ,
435
435
if flags { "[FLAGS]" } else { "" } ,
436
436
if opts {
437
437
if num_req_opts != self . opts. len( ) && !req_opts. is_empty( ) {
@@ -537,7 +537,9 @@ impl<'a, 'v, 'ab, 'u, 'ar> App<'a, 'v, 'ab, 'u, 'ar>{
537
537
}
538
538
539
539
fn print_version ( & self , quit : bool ) {
540
- println ! ( "{} {}" , self . bin_name. clone( ) . unwrap_or( self . name. clone( ) ) , self . version. unwrap_or( "" ) ) ;
540
+ // Print the binary name if existing, but replace all spaces with hyphens in case we're
541
+ // dealing with subcommands i.e. git mv is translated to git-mv
542
+ println ! ( "{} {}" , & self . bin_name. clone( ) . unwrap_or( self . name. clone( ) ) [ ..] . replace( " " , "-" ) , self . version. unwrap_or( "" ) ) ;
541
543
if quit { self . exit ( ) ; }
542
544
}
543
545
@@ -698,7 +700,8 @@ impl<'a, 'v, 'ab, 'u, 'ar> App<'a, 'v, 'ab, 'u, 'ar>{
698
700
if let Some ( sc_name) = subcmd_name {
699
701
if let Some ( ref mut sc) = self . subcommands . get_mut ( & sc_name) {
700
702
let mut new_matches = ArgMatches :: new ( ) ;
701
- sc. bin_name = Some ( format ! ( "{}{}{}" , self . bin_name. clone( ) . unwrap_or( "" . to_owned( ) ) , if self . bin_name. is_some( ) { "-" } else { "" } , sc. name. clone( ) ) ) ;
703
+ // bin_name should be parent's bin_name + the sc's name seperated by a space
704
+ sc. bin_name = Some ( format ! ( "{}{}{}" , self . bin_name. clone( ) . unwrap_or( "" . to_owned( ) ) , if self . bin_name. is_some( ) { " " } else { "" } , sc. name. clone( ) ) ) ;
702
705
sc. get_matches_from ( & mut new_matches, it) ;
703
706
matches. subcommand = Some ( Box :: new ( SubCommand {
704
707
name : sc. name . clone ( ) ,
0 commit comments