@@ -74,7 +74,7 @@ pub(crate) fn synopsis(roff: &mut Roff, cmd: &clap::Command) {
74
74
line. push ( roman ( " " ) ) ;
75
75
}
76
76
77
- if cmd. has_subcommands ( ) {
77
+ if cmd. has_subcommands ( ) && !cmd . is_flatten_help_set ( ) {
78
78
let ( lhs, rhs) = subcommand_markers ( cmd) ;
79
79
line. push ( roman ( lhs) ) ;
80
80
line. push ( italic (
@@ -220,6 +220,71 @@ pub(crate) fn subcommands(roff: &mut Roff, cmd: &clap::Command, section: &str) {
220
220
}
221
221
}
222
222
223
+ pub ( crate ) fn flat_subcommands ( roff : & mut Roff , cmd : & clap:: Command , section : & str ) {
224
+ for sub in cmd. get_subcommands ( ) . filter ( |s| !s. is_hide_set ( ) ) {
225
+ roff. control ( "TP" , [ ] ) ;
226
+
227
+ let name = sub. get_name ( ) ;
228
+ let mut line = vec ! [ bold( name) , roman( " " ) ] ;
229
+
230
+ for opt in sub. get_arguments ( ) . filter ( |i| !i. is_hide_set ( ) ) {
231
+ if opt. get_short ( ) == Some ( 'h' ) || opt. get_long ( ) == Some ( "help" ) {
232
+ continue ;
233
+ }
234
+ let ( lhs, rhs) = option_markers ( opt) ;
235
+ match ( opt. get_short ( ) , opt. get_long ( ) ) {
236
+ ( Some ( short) , Some ( long) ) => {
237
+ line. push ( roman ( lhs) ) ;
238
+ line. push ( bold ( format ! ( "-{short}" ) ) ) ;
239
+ line. push ( roman ( "|" ) ) ;
240
+ line. push ( bold ( format ! ( "--{long}" , ) ) ) ;
241
+ line. push ( roman ( rhs) ) ;
242
+ }
243
+ ( Some ( short) , None ) => {
244
+ line. push ( roman ( lhs) ) ;
245
+ line. push ( bold ( format ! ( "-{short} " ) ) ) ;
246
+ line. push ( roman ( rhs) ) ;
247
+ }
248
+ ( None , Some ( long) ) => {
249
+ line. push ( roman ( lhs) ) ;
250
+ line. push ( bold ( format ! ( "--{long}" ) ) ) ;
251
+ line. push ( roman ( rhs) ) ;
252
+ }
253
+ ( None , None ) => continue ,
254
+ } ;
255
+
256
+ if matches ! ( opt. get_action( ) , ArgAction :: Count ) {
257
+ line. push ( roman ( "..." ) ) ;
258
+ }
259
+ line. push ( roman ( " " ) ) ;
260
+ }
261
+
262
+ for arg in sub. get_positionals ( ) {
263
+ let ( lhs, rhs) = option_markers ( arg) ;
264
+ line. push ( roman ( lhs) ) ;
265
+ if let Some ( value) = arg. get_value_names ( ) {
266
+ line. push ( italic ( value. join ( " " ) ) ) ;
267
+ } else {
268
+ line. push ( italic ( arg. get_id ( ) . as_str ( ) ) ) ;
269
+ }
270
+ line. push ( roman ( rhs) ) ;
271
+ line. push ( roman ( " " ) ) ;
272
+ }
273
+
274
+ if let Some ( about) = sub. get_long_about ( ) . or_else ( || sub. get_about ( ) ) {
275
+ line. push ( roman ( "\n " ) ) ;
276
+ line. push ( roman ( about. to_string ( ) ) ) ;
277
+ }
278
+
279
+ if let Some ( after_help) = sub. get_after_help ( ) {
280
+ line. push ( roman ( "\n " ) ) ;
281
+ line. push ( roman ( after_help. to_string ( ) ) ) ;
282
+ }
283
+
284
+ roff. text ( line) ;
285
+ }
286
+ }
287
+
223
288
pub ( crate ) fn version ( cmd : & clap:: Command ) -> String {
224
289
format ! (
225
290
"v{}" ,
0 commit comments