Skip to content

Commit

Permalink
imp(Groups): formats positional args in groups in a better way
Browse files Browse the repository at this point in the history
  • Loading branch information
kbknapp committed May 9, 2016
1 parent 250ed41 commit fef1115
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/app/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -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());
}
}
}
Expand Down Expand Up @@ -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());
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,11 @@ impl Error {
process::exit(0);
}

#[doc(hidden)]
pub fn write_to<W: Write>(&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<O>, usage: U) -> Self
where A: AnyArg<'a, 'b> + Display,
Expand Down

0 comments on commit fef1115

Please sign in to comment.