mirror of
https://github.com/clap-rs/clap
synced 2025-01-22 01:14:59 +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 mut num_req_pos = 0;
|
||||||
let req_pos = self.positionals_idx.values().filter_map(|ref x| if x.required || self.required.contains(x.name) {
|
let req_pos = self.positionals_idx.values().filter_map(|ref x| if x.required || self.required.contains(x.name) {
|
||||||
num_req_pos += 1;
|
num_req_pos += 1;
|
||||||
Some(x.name)
|
if x.multiple {
|
||||||
|
Some(format!("<{}>...", x.name))
|
||||||
|
} else {
|
||||||
|
Some(format!("<{}>", x.name))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
None
|
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 mut num_req_opts = 0;
|
||||||
let req_opts = self.opts.values().filter_map(|x| if x.required || self.required.contains(x.name) {
|
let req_opts = self.opts.values().filter_map(|x| if x.required || self.required.contains(x.name) {
|
||||||
num_req_opts += 1;
|
num_req_opts += 1;
|
||||||
|
@ -516,7 +520,7 @@ impl<'a, 'v, 'ab, 'u, 'ar> App<'a, 'v, 'ab, 'u, 'ar>{
|
||||||
println!("");
|
println!("");
|
||||||
println!("POSITIONAL ARGUMENTS:");
|
println!("POSITIONAL ARGUMENTS:");
|
||||||
for v in self.positionals_idx.values() {
|
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 {
|
if let Some(h) = v.help {
|
||||||
format!("{}{}",
|
format!("{}{}",
|
||||||
h,
|
h,
|
||||||
|
|
Loading…
Reference in a new issue