Skip to content

Commit

Permalink
imp: options that use require_equals(true) now display the equals s…
Browse files Browse the repository at this point in the history
…ign in help messages, usage strings, and errors"

Closes #903
  • Loading branch information
kbknapp committed Mar 17, 2017
1 parent 16764bf commit c8eb038
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/app/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,13 @@ impl<'a> Help<'a> {
}
try!(color!(self, "--{}", l, good))
}
try!(write!(self.writer, " "));

let sep = if arg.is_set(ArgSettings::RequireEquals) {
"="
} else {
" "
};
try!(write!(self.writer, "{}", sep));
} else if let Some(l) = arg.long() {
if arg.short().is_some() {
try!(write!(self.writer, ", "));
Expand Down
9 changes: 7 additions & 2 deletions src/args/arg_builder/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,16 @@ impl<'n, 'e> From<Arg<'n, 'e>> for OptBuilder<'n, 'e> {
impl<'n, 'e> Display for OptBuilder<'n, 'e> {
fn fmt(&self, f: &mut Formatter) -> Result {
debugln!("OptBuilder::fmt");
let sep = if self.b.is_set(ArgSettings::RequireEquals) {
"="
} else {
" "
};
// Write the name such --long or -l
if let Some(l) = self.s.long {
try!(write!(f, "--{} ", l));
try!(write!(f, "--{}{}", l, sep));
} else {
try!(write!(f, "-{} ", self.s.short.unwrap()));
try!(write!(f, "-{}{}", self.s.short.unwrap(), sep));
}

// Write the values such as <name1> <name2>
Expand Down

0 comments on commit c8eb038

Please sign in to comment.