From fef11154fb7430d1cbf04a672aabb366e456a368 Mon Sep 17 00:00:00 2001 From: Kevin K Date: Sun, 8 May 2016 21:33:27 -0400 Subject: [PATCH] imp(Groups): formats positional args in groups in a better way --- src/app/parser.rs | 8 ++++---- src/errors.rs | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/app/parser.rs b/src/app/parser.rs index 95170a0c909..dbd6ba97d5a 100644 --- a/src/app/parser.rs +++ b/src/app/parser.rs @@ -303,7 +303,7 @@ impl<'a, 'b> Parser<'a, 'b> continue; } if let Some(p) = self.positionals.values().filter(|x| &x.name == &p).next() { - pmap.insert(p.index, p.to_string()); + pmap.insert(p.index, p.name.to_owned()); } } for (_, s) in pmap { @@ -324,7 +324,7 @@ impl<'a, 'b> Parser<'a, 'b> for g in grps.into_iter() { let g_string = self.args_in_group(g) .join("|"); - ret_val.push_back(format!("[{}]", &g_string[..g_string.len()])); + ret_val.push_back(format!("<{}>", &g_string[..g_string.len()])); } ret_val @@ -683,7 +683,7 @@ impl<'a, 'b> Parser<'a, 'b> if let Some(pos) = self.positionals.values().filter(|p| &p.name == &k).next() { if let Some(ref bl) = pos.blacklist { if bl.contains(&name) { - return Some(pos.to_string()); + return Some(pos.name.to_owned()); } } } @@ -757,7 +757,7 @@ impl<'a, 'b> Parser<'a, 'b> .values() .filter(|p| &p.name == n) .next() { - args.push(p.to_string()); + args.push(p.name.to_owned()); } } diff --git a/src/errors.rs b/src/errors.rs index ef1ae7df54e..dc33c597443 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -354,6 +354,11 @@ impl Error { process::exit(0); } + #[doc(hidden)] + pub fn write_to(&self, w: &mut W) -> io::Result<()> { + write!(w, "{}", self.message) + } + #[doc(hidden)] pub fn argument_conflict<'a, 'b, A, O, U>(arg: &A, other: Option, usage: U) -> Self where A: AnyArg<'a, 'b> + Display,