Skip to content

Commit

Permalink
im(ErrorMessages): improves error messages and corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
kbknapp committed May 3, 2015
1 parent 93c4a72 commit a29c398
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{

if self.blacklist.contains(p.name) {
matches.args.remove(p.name);
self.report_error(format!("The argument \"{}\" cannot be used with {}",
self.report_error(format!("The argument '{}' cannot be used with {}",
p,
match self.blacklisted_from(p.name, &matches) {
Some(name) => name,
Expand Down Expand Up @@ -1290,7 +1290,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
if let Some(ref vals) = ma.values {
if vals.len() as u8 == num {
self.report_error(format!("The argument \"{}\" was found, \
but {} doesn't expect any more values", arg, p),
but '{}' wasn't expecting any more values", arg, p),
true,
true,
Some(matches.args.keys()
Expand Down Expand Up @@ -1343,7 +1343,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
parse_group_reqs!(self, p);

} else {
self.report_error(format!("The argument \"{}\" was found, but {} wasn't \
self.report_error(format!("The argument \"{}\" was found, but '{}' wasn't \
expecting any", arg,
self.bin_name.clone().unwrap_or(self.name.clone())),
true,
Expand All @@ -1370,7 +1370,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
.map(|s| *s)
.collect::<HashSet<_>>())
.iter()
.fold(String::new(), |acc, s| acc + &format!("\t{}\n",s)[..])),
.fold(String::new(), |acc, s| acc + &format!("\t'{}'\n",s)[..])),
true,
true,
Some(matches.args.keys().map(|k| *k).collect::<Vec<_>>()));
Expand Down Expand Up @@ -1399,7 +1399,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
.map(|s| *s)
.collect::<HashSet<_>>())
.iter()
.fold(String::new(), |acc, s| acc + &format!("\t{}\n",s)[..])),
.fold(String::new(), |acc, s| acc + &format!("\t'{}'\n",s)[..])),
true,
true,
Some(matches.args.keys().map(|k| *k).collect::<Vec<_>>()));
Expand Down Expand Up @@ -1622,7 +1622,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
// Ensure this flag isn't on the mutually excludes list
if self.blacklist.contains(v.name) {
matches.args.remove(v.name);
self.report_error(format!("The argument {} cannot be used with {}",
self.report_error(format!("The argument '{}' cannot be used with {}",
v,
match self.blacklisted_from(v.name, matches) {
Some(name) => name,
Expand Down Expand Up @@ -1857,7 +1857,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
for name in self.blacklist.iter() {
if matches.args.contains_key(name) {
matches.args.remove(name);
self.report_error(format!("The argument {} cannot be used with {}",
self.report_error(format!("The argument '{}' cannot be used with {}",
if let Some(ref flag) = self.flags.get(name) {
format!("{}", flag)
} else if let Some(ref opt) = self.opts.get(name) {
Expand All @@ -1876,7 +1876,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
for n in grp.args.iter() {
if matches.args.contains_key(n) {
matches.args.remove(n);
self.report_error(format!("The argument {} cannot be used with one or \
self.report_error(format!("The argument '{}' cannot be used with one or \
more of the other specified arguments",
if let Some(ref flag) = self.flags.get(n) {
format!("{}", flag)
Expand Down Expand Up @@ -1905,7 +1905,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
if let Some(f) = self.opts.get(name) {
if let Some(num) = f.num_vals {
if num != vals.len() as u8 {
self.report_error(format!("The argument {} requires {} values, \
self.report_error(format!("The argument '{}' requires {} values, \
but {} w{} provided",
f,
num,
Expand All @@ -1918,7 +1918,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
}
if let Some(num) = f.max_vals {
if (vals.len() as u8) > num {
self.report_error(format!("The argument {} requires no more than {} \
self.report_error(format!("The argument '{}' requires no more than {} \
values, but {} w{} provided",
f,
num,
Expand All @@ -1931,7 +1931,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
}
if let Some(num) = f.min_vals {
if (vals.len() as u8) < num {
self.report_error(format!("The argument {} requires at least {} \
self.report_error(format!("The argument '{}' requires at least {} \
values, but {} w{} provided",
f,
num,
Expand All @@ -1946,7 +1946,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
self.positionals_name.get(name).unwrap()) {
if let Some(num) = f.num_vals {
if num != vals.len() as u8 {
self.report_error(format!("The argument {} requires {} values, \
self.report_error(format!("The argument '{}' requires {} values, \
but {} w{} provided",
f,
num,
Expand All @@ -1959,7 +1959,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
}
if let Some(num) = f.max_vals {
if num > vals.len() as u8 {
self.report_error(format!("The argument {} requires no more than {} \
self.report_error(format!("The argument '{}' requires no more than {} \
values, but {} w{} provided",
f,
num,
Expand All @@ -1972,7 +1972,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
}
if let Some(num) = f.min_vals {
if num < vals.len() as u8 {
self.report_error(format!("The argument {} requires at least {} \
self.report_error(format!("The argument '{}' requires at least {} \
values, but {} w{} provided",
f,
num,
Expand Down

0 comments on commit a29c398

Please sign in to comment.