im(Options): adds number of values to options in help/usage

This commit is contained in:
Kevin K 2015-05-04 21:16:49 -04:00
parent 45e481cb1c
commit c1c993c419
2 changed files with 19 additions and 7 deletions

View file

@ -1009,16 +1009,20 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
vec.iter().fold(String::new(), |acc, s| {
acc + &format!("<{}> ", s)[..]
})
} else if let Some(num) = v.num_vals {
(0..num).fold(String::new(), |acc, _| {
acc + &format!("<{}> ", v.name)[..]
})
} else {
format!("<{}>{}", v.name, if v.multiple{"..."} else {""})
}),
if v.long.is_some() {
self.get_spaces(
(longest_opt) - (v.long.unwrap().len() + v.name.len() + mult + 1)
)
} else {
self.get_spaces((longest_opt + 3) - (v.name.len() + mult))
},
if v.long.is_some() {
self.get_spaces(
(longest_opt) - (v.long.unwrap().len() + v.name.len() + mult + 1)
)
} else {
self.get_spaces((longest_opt + 3) - (v.name.len() + mult))
},
get_help!(v) );
}
}

View file

@ -42,6 +42,14 @@ impl<'n> Display for OptBuilder<'n> {
format!("-{}", self.short.unwrap())
},
vec.iter().fold(String::new(),|acc, i| acc + &format!(" <{}>",i)[..]) )
} else if let Some(num) = self.num_vals {
format!("{}{}",
if self.long.is_some() {
format!("--{}", self.long.unwrap())
} else {
format!("-{}", self.short.unwrap())
},
(0..num).fold(String::new(), |acc, _| acc + &format!(" <{}>", self.name)[..]) )
} else {
format!("{} <{}>{}",
if self.long.is_some() {