Skip to content

Commit

Permalink
im(Options): adds number of values to options in help/usage
Browse files Browse the repository at this point in the history
  • Loading branch information
kbknapp committed May 5, 2015
1 parent 45e481c commit c1c993c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) );
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/args/argbuilder/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit c1c993c

Please sign in to comment.