mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
feat(help): add '...' to indicate multiple values supported
This commit is contained in:
parent
fb3ccd7aaf
commit
297ddba770
1 changed files with 7 additions and 3 deletions
10
src/app.rs
10
src/app.rs
|
@ -417,11 +417,15 @@ impl<'a, 'v, 'ab, 'u, 'ar> App<'a, 'v, 'ab, 'u, 'ar>{
|
|||
let mut num_req_pos = 0;
|
||||
let req_pos = self.positionals_idx.values().filter_map(|ref x| if x.required || self.required.contains(x.name) {
|
||||
num_req_pos += 1;
|
||||
Some(x.name)
|
||||
if x.multiple {
|
||||
Some(format!("<{}>...", x.name))
|
||||
} else {
|
||||
Some(format!("<{}>", x.name))
|
||||
}
|
||||
} else {
|
||||
None
|
||||
})
|
||||
.fold(String::new(), |acc, ref name| acc + &format!("<{}> ", name)[..]);
|
||||
.fold(String::new(), |acc, ref name| acc + &format!("{} ", name)[..]);
|
||||
let mut num_req_opts = 0;
|
||||
let req_opts = self.opts.values().filter_map(|x| if x.required || self.required.contains(x.name) {
|
||||
num_req_opts += 1;
|
||||
|
@ -516,7 +520,7 @@ impl<'a, 'v, 'ab, 'u, 'ar> App<'a, 'v, 'ab, 'u, 'ar>{
|
|||
println!("");
|
||||
println!("POSITIONAL ARGUMENTS:");
|
||||
for v in self.positionals_idx.values() {
|
||||
println!("\t{}\t\t{}", v.name,
|
||||
println!("\t{}\t\t{}", if v.multiple {format!("{}...",v.name)} else {v.name.to_owned()},
|
||||
if let Some(h) = v.help {
|
||||
format!("{}{}",
|
||||
h,
|
||||
|
|
Loading…
Reference in a new issue