File tree Expand file tree Collapse file tree 2 files changed +39
-1
lines changed
Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -657,12 +657,15 @@ impl HelpTemplate<'_, '_> {
657657 help. indent ( "" , & trailing_indent) ;
658658 self . writer . push_styled ( & help) ;
659659
660+ let mut has_possible_values = false ;
660661 if let Some ( arg) = arg {
661662 if !arg. is_hide_possible_values_set ( ) && self . use_long_pv ( arg) {
662663 const DASH_SPACE : usize = "- " . len ( ) ;
663664 let possible_vals = arg. get_possible_values ( ) ;
664665 if !possible_vals. is_empty ( ) {
665666 debug ! ( "HelpTemplate::help: Found possible vals...{possible_vals:?}" ) ;
667+ has_possible_values = true ;
668+
666669 let longest = possible_vals
667670 . iter ( )
668671 . filter ( |f| !f. is_hide_set ( ) )
@@ -709,7 +712,7 @@ impl HelpTemplate<'_, '_> {
709712
710713 if !spec_vals. is_empty ( ) && next_line_specs {
711714 let mut help = StyledStr :: new ( ) ;
712- if !help_is_empty {
715+ if !help_is_empty || has_possible_values {
713716 let sep = "\n \n " ;
714717 help. push_str ( sep) ;
715718 }
Original file line number Diff line number Diff line change @@ -3107,6 +3107,41 @@ fn too_many_value_names_panics() {
31073107 . debug_assert ( ) ;
31083108}
31093109
3110+ #[ test]
3111+ fn help_enum_arg_with_no_description ( ) {
3112+ let cmd = Command :: new ( "test" ) . arg (
3113+ Arg :: new ( "config" )
3114+ . action ( ArgAction :: Set )
3115+ // .help("No help description for this argument")
3116+ . short ( 'c' )
3117+ . long ( "config" )
3118+ . value_name ( "MODE" )
3119+ . value_parser ( [
3120+ PossibleValue :: new ( "fast" ) ,
3121+ PossibleValue :: new ( "slow" ) . help ( "slower than fast" ) ,
3122+ PossibleValue :: new ( "secret speed" ) . hide ( true ) ,
3123+ ] )
3124+ . default_value ( "fast" ) ,
3125+ ) ;
3126+
3127+ let expected = str![ [ r#"
3128+ Usage: test [OPTIONS]
3129+
3130+ Options:
3131+ -c, --config <MODE>
3132+ Possible values:
3133+ - fast
3134+ - slow: slower than fast
3135+
3136+ [default: fast]
3137+
3138+ -h, --help
3139+ Print help (see a summary with '-h')
3140+
3141+ "# ] ] ;
3142+ utils:: assert_output ( cmd, "test --help" , expected, false ) ;
3143+ }
3144+
31103145#[ test]
31113146fn disabled_help_flag ( ) {
31123147 let res = Command :: new ( "foo" )
You can’t perform that action at this time.
0 commit comments