@@ -407,6 +407,7 @@ where
407407 }
408408
409409 fn print_short_help ( & mut self , item : & Item < T > ) {
410+ let mut has_options = false ;
410411 match item. item_type {
411412 ItemType :: Callback { parameters, .. } => {
412413 write ! ( self . context, " {}" , item. command) . unwrap ( ) ;
@@ -419,16 +420,11 @@ where
419420 Parameter :: Optional { parameter_name, .. } => {
420421 write ! ( self . context, " [ <{}> ]" , parameter_name) . unwrap ( ) ;
421422 }
422- Parameter :: Named { parameter_name , .. } => {
423- write ! ( self . context , " [ --{} ]" , parameter_name ) . unwrap ( ) ;
423+ Parameter :: Named { .. } => {
424+ has_options = true ;
424425 }
425- Parameter :: NamedValue {
426- parameter_name,
427- argument_name,
428- ..
429- } => {
430- write ! ( self . context, " [ --{}={} ]" , parameter_name, argument_name)
431- . unwrap ( ) ;
426+ Parameter :: NamedValue { .. } => {
427+ has_options = true ;
432428 }
433429 }
434430 }
@@ -441,10 +437,10 @@ where
441437 write ! ( self . context, " {}" , item. command) . unwrap ( ) ;
442438 }
443439 }
444- if let Some ( help) = item. help {
445- let mut help_line_iter = help. split ( '\n' ) ;
446- writeln ! ( self . context, " - {}" , help_line_iter. next( ) . unwrap( ) ) . unwrap ( ) ;
440+ if has_options {
441+ write ! ( self . context, " [OPTIONS...]" ) . unwrap ( ) ;
447442 }
443+ writeln ! ( self . context) . unwrap ( ) ;
448444 }
449445
450446 fn print_long_help ( & mut self , item : & Item < T > ) {
@@ -475,6 +471,7 @@ where
475471 }
476472 }
477473 writeln ! ( self . context, "\n \n PARAMETERS:" ) . unwrap ( ) ;
474+ let default_help = "Undocumented option" ;
478475 for param in parameters. iter ( ) {
479476 match param {
480477 Parameter :: Mandatory {
@@ -483,9 +480,9 @@ where
483480 } => {
484481 writeln ! (
485482 self . context,
486- " <{0}>\n - {1}" ,
483+ " <{0}>\n {1}\n " ,
487484 parameter_name,
488- help. unwrap_or( "" ) ,
485+ help. unwrap_or( default_help ) ,
489486 )
490487 . unwrap ( ) ;
491488 }
@@ -495,9 +492,9 @@ where
495492 } => {
496493 writeln ! (
497494 self . context,
498- " <{0}>\n - {1}" ,
495+ " <{0}>\n {1}\n " ,
499496 parameter_name,
500- help. unwrap_or( "No help text found" ) ,
497+ help. unwrap_or( default_help ) ,
501498 )
502499 . unwrap ( ) ;
503500 }
@@ -507,9 +504,9 @@ where
507504 } => {
508505 writeln ! (
509506 self . context,
510- " --{0}\n - {1}" ,
507+ " --{0}\n {1}\n " ,
511508 parameter_name,
512- help. unwrap_or( "No help text found" ) ,
509+ help. unwrap_or( default_help ) ,
513510 )
514511 . unwrap ( ) ;
515512 }
@@ -520,10 +517,10 @@ where
520517 } => {
521518 writeln ! (
522519 self . context,
523- " --{0}={1}\n - {2}" ,
520+ " --{0}={1}\n {2}\n " ,
524521 parameter_name,
525522 argument_name,
526- help. unwrap_or( "No help text found" ) ,
523+ help. unwrap_or( default_help ) ,
527524 )
528525 . unwrap ( ) ;
529526 }
0 commit comments