imp: options that use require_equals(true) now display the equals sign in help messages, usage strings, and errors"

Closes #903
This commit is contained in:
Kevin K 2017-03-16 21:43:36 -04:00
parent 16764bfa27
commit c8eb0384d3
No known key found for this signature in database
GPG key ID: 17218E4B3692F01A
2 changed files with 14 additions and 3 deletions

View file

@ -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, ", "));

View file

@ -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>