Skip to content

Commit 76a016a

Browse files
committed
refactor(man): Allow possible values to output Roff
1 parent 9db8234 commit 76a016a

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

clap_mangen/src/render.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ fn possible_options(roff: &mut Roff, arg: &Arg, arg_help_written: bool) {
206206
roff.control("RS", ["14"]);
207207
for line in possible_values_text {
208208
roff.control("IP", ["\\(bu", "2"]);
209-
roff.text([roman(line)]);
209+
roff.extend([line]);
210210
}
211211
roff.control("RE", []);
212212
}
@@ -346,7 +346,7 @@ fn option_default_values(opt: &Arg) -> Option<String> {
346346
None
347347
}
348348

349-
fn get_possible_values(arg: &Arg) -> Option<Vec<String>> {
349+
fn get_possible_values(arg: &Arg) -> Option<Vec<Roff>> {
350350
if arg.is_hide_possible_values_set() {
351351
return None;
352352
}
@@ -361,14 +361,20 @@ fn get_possible_values(arg: &Arg) -> Option<Vec<String>> {
361361
None
362362
}
363363

364-
fn format_possible_values(possibles: &Vec<&clap::builder::PossibleValue>) -> Vec<String> {
364+
fn format_possible_values(possibles: &Vec<&clap::builder::PossibleValue>) -> Vec<Roff> {
365365
let mut lines = vec![];
366366
for value in possibles {
367+
let mut roff = Roff::default();
367368
let val_name = value.get_name();
368369
match value.get_help() {
369-
Some(help) => lines.push(format!("{val_name}: {help}")),
370-
None => lines.push(val_name.to_owned()),
370+
Some(help) => {
371+
roff.text([roman(format!("{val_name}: {help}"))]);
372+
}
373+
None => {
374+
roff.text([roman(val_name.to_owned())]);
375+
}
371376
}
377+
lines.push(roff);
372378
}
373379
lines
374380
}

0 commit comments

Comments
 (0)