Skip to content

Commit

Permalink
Add ellipsis to repeatable args
Browse files Browse the repository at this point in the history
  • Loading branch information
drivasperez committed Oct 30, 2022
1 parent 44c6ddc commit 7e3fbde
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
11 changes: 7 additions & 4 deletions clap_mangen/src/render.rs
@@ -1,3 +1,4 @@
use clap::ArgAction;
use roff::{bold, italic, roman, Inline, Roff};

pub(crate) fn subcommand_heading(cmd: &clap::Command) -> &str {
Expand Down Expand Up @@ -39,22 +40,24 @@ pub(crate) fn synopsis(roff: &mut Roff, cmd: &clap::Command) {
line.push(roman("|"));
line.push(bold(&format!("--{}", long)));
line.push(roman(rhs));
line.push(roman(" "));
}
(Some(short), None) => {
line.push(roman(lhs));
line.push(bold(&format!("-{} ", short)));
line.push(roman(rhs));
line.push(roman(" "));
}
(None, Some(long)) => {
line.push(roman(lhs));
line.push(bold(&format!("--{}", long)));
line.push(roman(rhs));
line.push(roman(" "));
}
(None, None) => (),
(None, None) => continue,
};

if matches!(opt.get_action(), ArgAction::Count) {
line.push(roman("..."))
}
line.push(roman(" "));
}

for arg in cmd.get_positionals() {
Expand Down
2 changes: 1 addition & 1 deletion clap_mangen/tests/snapshots/feature_sample.bash.roff
Expand Up @@ -4,7 +4,7 @@
.SH NAME
my/-app /- Tests completions
.SH SYNOPSIS
/fBmy/-app/fR [/fB/-c/fR|/fB/-/-config/fR] [/fB/-h/fR|/fB/-/-help/fR] [/fB/-V/fR|/fB/-/-version/fR] [/fIfile/fR] [/fIchoice/fR] [/fIsubcommands/fR]
/fBmy/-app/fR [/fB/-c/fR|/fB/-/-config/fR]... [/fB/-h/fR|/fB/-/-help/fR] [/fB/-V/fR|/fB/-/-version/fR] [/fIfile/fR] [/fIchoice/fR] [/fIsubcommands/fR]
.SH DESCRIPTION
Tests completions
.SH OPTIONS
Expand Down
2 changes: 1 addition & 1 deletion clap_mangen/tests/snapshots/special_commands.bash.roff
Expand Up @@ -4,7 +4,7 @@
.SH NAME
my/-app /- Tests completions
.SH SYNOPSIS
/fBmy/-app/fR [/fB/-c/fR|/fB/-/-config/fR] [/fB/-h/fR|/fB/-/-help/fR] [/fB/-V/fR|/fB/-/-version/fR] [/fIfile/fR] [/fIchoice/fR] [/fIsubcommands/fR]
/fBmy/-app/fR [/fB/-c/fR|/fB/-/-config/fR]... [/fB/-h/fR|/fB/-/-help/fR] [/fB/-V/fR|/fB/-/-version/fR] [/fIfile/fR] [/fIchoice/fR] [/fIsubcommands/fR]
.SH DESCRIPTION
Tests completions
.SH OPTIONS
Expand Down
2 changes: 1 addition & 1 deletion clap_mangen/tests/snapshots/sub_subcommands.bash.roff
Expand Up @@ -4,7 +4,7 @@
.SH NAME
my/-app /- Tests completions
.SH SYNOPSIS
/fBmy/-app/fR [/fB/-c/fR|/fB/-/-config/fR] [/fB/-h/fR|/fB/-/-help/fR] [/fB/-V/fR|/fB/-/-version/fR] [/fIfile/fR] [/fIchoice/fR] [/fIsubcommands/fR]
/fBmy/-app/fR [/fB/-c/fR|/fB/-/-config/fR]... [/fB/-h/fR|/fB/-/-help/fR] [/fB/-V/fR|/fB/-/-version/fR] [/fIfile/fR] [/fIchoice/fR] [/fIsubcommands/fR]
.SH DESCRIPTION
Tests completions
.SH OPTIONS
Expand Down

0 comments on commit 7e3fbde

Please sign in to comment.