@@ -193,33 +193,22 @@ pub(crate) fn options(roff: &mut Roff, items: &[&Arg]) {
193193}
194194
195195fn possible_options ( roff : & mut Roff , arg : & Arg , arg_help_written : bool ) {
196- if let Some ( ( possible_values_text, with_help ) ) = get_possible_values ( arg) {
196+ if let Some ( possible_values_text) = get_possible_values ( arg) {
197197 if arg_help_written {
198198 // It looks nice to have a separation between the help and the values
199199 roff. text ( [ Inline :: LineBreak ] ) ;
200200 }
201- if with_help {
202- roff. text ( [ Inline :: LineBreak , italic ( "Possible values:" ) ] ) ;
203-
204- // Need to indent twice to get it to look right, because .TP heading indents, but
205- // that indent doesn't Carry over to the .IP for the bullets. The standard shift
206- // size is 7 for terminal devices
207- roff. control ( "RS" , [ "14" ] ) ;
208- for line in possible_values_text {
209- roff. control ( "IP" , [ "\\ (bu" , "2" ] ) ;
210- roff. text ( [ roman ( line) ] ) ;
211- }
212- roff. control ( "RE" , [ ] ) ;
213- } else {
214- let possible_value_text: Vec < Inline > = vec ! [
215- Inline :: LineBreak ,
216- roman( "[" ) ,
217- italic( "possible values: " ) ,
218- roman( possible_values_text. join( ", " ) ) ,
219- roman( "]" ) ,
220- ] ;
221- roff. text ( possible_value_text) ;
201+ roff. text ( [ Inline :: LineBreak , italic ( "Possible values:" ) ] ) ;
202+
203+ // Need to indent twice to get it to look right, because .TP heading indents, but
204+ // that indent doesn't Carry over to the .IP for the bullets. The standard shift
205+ // size is 7 for terminal devices
206+ roff. control ( "RS" , [ "14" ] ) ;
207+ for line in possible_values_text {
208+ roff. control ( "IP" , [ "\\ (bu" , "2" ] ) ;
209+ roff. extend ( [ line] ) ;
222210 }
211+ roff. control ( "RE" , [ ] ) ;
223212 }
224213}
225214
@@ -357,7 +346,7 @@ fn option_default_values(opt: &Arg) -> Option<String> {
357346 None
358347}
359348
360- fn get_possible_values ( arg : & Arg ) -> Option < ( Vec < String > , bool ) > {
349+ fn get_possible_values ( arg : & Arg ) -> Option < Vec < Roff > > {
361350 if arg. is_hide_possible_values_set ( ) {
362351 return None ;
363352 }
@@ -372,21 +361,22 @@ fn get_possible_values(arg: &Arg) -> Option<(Vec<String>, bool)> {
372361 None
373362}
374363
375- fn format_possible_values ( possibles : & Vec < & clap:: builder:: PossibleValue > ) -> ( Vec < String > , bool ) {
364+ fn format_possible_values ( possibles : & Vec < & clap:: builder:: PossibleValue > ) -> Vec < Roff > {
376365 let mut lines = vec ! [ ] ;
377- let with_help = possibles. iter ( ) . any ( |p| p. get_help ( ) . is_some ( ) ) ;
378- if with_help {
379- for value in possibles {
380- let val_name = value. get_name ( ) ;
381- match value. get_help ( ) {
382- Some ( help) => lines. push ( format ! ( "{val_name}: {help}" ) ) ,
383- None => lines. push ( val_name. to_string ( ) ) ,
366+ for value in possibles {
367+ let mut roff = Roff :: default ( ) ;
368+ let val_name = value. get_name ( ) ;
369+ match value. get_help ( ) {
370+ Some ( help) => {
371+ roff. text ( [ roman ( format ! ( "{val_name}: {help}" ) ) ] ) ;
372+ }
373+ None => {
374+ roff. text ( [ roman ( val_name. to_owned ( ) ) ] ) ;
384375 }
385376 }
386- } else {
387- lines. append ( & mut possibles. iter ( ) . map ( |p| p. get_name ( ) . to_string ( ) ) . collect ( ) ) ;
377+ lines. push ( roff) ;
388378 }
389- ( lines, with_help )
379+ lines
390380}
391381
392382fn subcommand_sort_key ( command : & clap:: Command ) -> ( usize , & str ) {
0 commit comments