mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
imp(Help): moves positionals to standard <> formatting
This commit is contained in:
parent
cff94579c1
commit
03dfe5ceff
1 changed files with 15 additions and 15 deletions
|
@ -112,7 +112,7 @@ impl<'n, 'e> PosBuilder<'n, 'e> {
|
|||
|
||||
impl<'n, 'e> Display for PosBuilder<'n, 'e> {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result {
|
||||
if self.settings.is_set(ArgSettings::Required) {
|
||||
// if self.settings.is_set(ArgSettings::Required) {
|
||||
if let Some(ref names) = self.val_names {
|
||||
try!(write!(f,
|
||||
"{}",
|
||||
|
@ -123,18 +123,18 @@ impl<'n, 'e> Display for PosBuilder<'n, 'e> {
|
|||
} else {
|
||||
try!(write!(f, "<{}>", self.name));
|
||||
}
|
||||
} else {
|
||||
if let Some(ref names) = self.val_names {
|
||||
try!(write!(f,
|
||||
"{}",
|
||||
names.values()
|
||||
.map(|n| format!("[{}]", n))
|
||||
.collect::<Vec<_>>()
|
||||
.join(" ")));
|
||||
} else {
|
||||
try!(write!(f, "[{}]", self.name));
|
||||
}
|
||||
}
|
||||
// } else {
|
||||
// if let Some(ref names) = self.val_names {
|
||||
// try!(write!(f,
|
||||
// "{}",
|
||||
// names.values()
|
||||
// .map(|n| format!("[{}]", n))
|
||||
// .collect::<Vec<_>>()
|
||||
// .join(" ")));
|
||||
// } else {
|
||||
// try!(write!(f, "[{}]", self.name));
|
||||
// }
|
||||
// }
|
||||
if self.settings.is_set(ArgSettings::Multiple) && self.val_names.is_none() {
|
||||
try!(write!(f, "..."));
|
||||
}
|
||||
|
@ -250,7 +250,7 @@ mod test {
|
|||
let mut p = PosBuilder::new("pos", 1);
|
||||
p.settings.set(ArgSettings::Multiple);
|
||||
|
||||
assert_eq!(&*format!("{}", p), "[pos]...");
|
||||
assert_eq!(&*format!("{}", p), "<pos>...");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -269,7 +269,7 @@ mod test {
|
|||
vm.insert(1, "file2");
|
||||
p2.val_names = Some(vm);
|
||||
|
||||
assert_eq!(&*format!("{}", p2), "[file1] [file2]");
|
||||
assert_eq!(&*format!("{}", p2), "<file1> <file2>");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in a new issue