mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 06:12:40 +00:00
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:
parent
16764bfa27
commit
c8eb0384d3
2 changed files with 14 additions and 3 deletions
|
@ -283,7 +283,13 @@ impl<'a> Help<'a> {
|
||||||
}
|
}
|
||||||
try!(color!(self, "--{}", l, good))
|
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() {
|
} else if let Some(l) = arg.long() {
|
||||||
if arg.short().is_some() {
|
if arg.short().is_some() {
|
||||||
try!(write!(self.writer, ", "));
|
try!(write!(self.writer, ", "));
|
||||||
|
|
|
@ -50,11 +50,16 @@ impl<'n, 'e> From<Arg<'n, 'e>> for OptBuilder<'n, 'e> {
|
||||||
impl<'n, 'e> Display for OptBuilder<'n, 'e> {
|
impl<'n, 'e> Display for OptBuilder<'n, 'e> {
|
||||||
fn fmt(&self, f: &mut Formatter) -> Result {
|
fn fmt(&self, f: &mut Formatter) -> Result {
|
||||||
debugln!("OptBuilder::fmt");
|
debugln!("OptBuilder::fmt");
|
||||||
|
let sep = if self.b.is_set(ArgSettings::RequireEquals) {
|
||||||
|
"="
|
||||||
|
} else {
|
||||||
|
" "
|
||||||
|
};
|
||||||
// Write the name such --long or -l
|
// Write the name such --long or -l
|
||||||
if let Some(l) = self.s.long {
|
if let Some(l) = self.s.long {
|
||||||
try!(write!(f, "--{} ", l));
|
try!(write!(f, "--{}{}", l, sep));
|
||||||
} else {
|
} else {
|
||||||
try!(write!(f, "-{} ", self.s.short.unwrap()));
|
try!(write!(f, "-{}{}", self.s.short.unwrap(), sep));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write the values such as <name1> <name2>
|
// Write the values such as <name1> <name2>
|
||||||
|
|
Loading…
Reference in a new issue