@@ -32,7 +32,24 @@ pub(crate) fn description(roff: &mut Roff, cmd: &clap::Command) {
3232pub ( crate ) fn synopsis ( roff : & mut Roff , cmd : & clap:: Command ) {
3333 let name = cmd. get_bin_name ( ) . unwrap_or_else ( || cmd. get_name ( ) ) ;
3434 let mut line = vec ! [ bold( name) , roman( " " ) ] ;
35+ let mut line = usage ( cmd, name) ;
3536
37+ if cmd. has_subcommands ( ) && !flatten {
38+ let ( lhs, rhs) = subcommand_markers ( cmd) ;
39+ line. push ( roman ( lhs) ) ;
40+ line. push ( italic (
41+ cmd. get_subcommand_value_name ( )
42+ . unwrap_or_else ( || subcommand_heading ( cmd) )
43+ . to_lowercase ( ) ,
44+ ) ) ;
45+ line. push ( roman ( rhs) ) ;
46+ }
47+ roff. text ( line) ;
48+ }
49+ }
50+
51+ fn usage ( cmd : & clap:: Command , name : & str ) -> Vec < Inline > {
52+ let mut line = vec ! [ bold( name) , roman( " " ) ] ;
3653 for opt in cmd. get_arguments ( ) . filter ( |i| !i. is_hide_set ( ) ) {
3754 let ( lhs, rhs) = option_markers ( opt) ;
3855 match ( opt. get_short ( ) , opt. get_long ( ) ) {
@@ -74,18 +91,7 @@ pub(crate) fn synopsis(roff: &mut Roff, cmd: &clap::Command) {
7491 line. push ( roman ( " " ) ) ;
7592 }
7693
77- if cmd. has_subcommands ( ) {
78- let ( lhs, rhs) = subcommand_markers ( cmd) ;
79- line. push ( roman ( lhs) ) ;
80- line. push ( italic (
81- cmd. get_subcommand_value_name ( )
82- . unwrap_or_else ( || subcommand_heading ( cmd) )
83- . to_lowercase ( ) ,
84- ) ) ;
85- line. push ( roman ( rhs) ) ;
86- }
87-
88- roff. text ( line) ;
94+ line
8995}
9096
9197pub ( crate ) fn options ( roff : & mut Roff , cmd : & clap:: Command ) {
0 commit comments