Fix an error being displayed weirdly

The Debug impl was being used instead of the Display one. Also, remove the full stops from the ends of all the error messages because I’ve decided it looks weird.
This commit is contained in:
Benjamin Sago 2017-08-19 22:17:53 +01:00
parent 02350c5a2a
commit 4c16f50565
5 changed files with 12 additions and 7 deletions

View File

@ -95,12 +95,13 @@ impl fmt::Display for Misfire {
InvalidOptions(ref e) => write!(f, "{}", e),
Help(ref text) => write!(f, "{}", text),
Version(ref version) => write!(f, "{}", version),
Conflict(ref a, ref b) => write!(f, "Option {} conflicts with option {}.", a, b),
Duplicate(ref a, ref b) => write!(f, "Flag {:?} conflicts with flag {:?}.", a, b),
Useless(ref a, false, ref b) => write!(f, "Option {} is useless without option {}.", a, b),
Useless(ref a, true, ref b) => write!(f, "Option {} is useless given option {}.", a, b),
Useless2(ref a, ref b1, ref b2) => write!(f, "Option {} is useless without options {} or {}.", a, b1, b2),
TreeAllAll => write!(f, "Option --tree is useless given --all --all."),
Conflict(ref a, ref b) => write!(f, "Option {} conflicts with option {}", a, b),
Duplicate(ref a, ref b) => if a == b { write!(f, "Flag {} was given twice", a) }
else { write!(f, "Flag {} conflicts with flag {}", a, b) },
Useless(ref a, false, ref b) => write!(f, "Option {} is useless without option {}", a, b),
Useless(ref a, true, ref b) => write!(f, "Option {} is useless given option {}", a, b),
Useless2(ref a, ref b1, ref b2) => write!(f, "Option {} is useless without options {} or {}", a, b1, b2),
TreeAllAll => write!(f, "Option --tree is useless given --all --all"),
FailedParse(ref e) => write!(f, "Failed to parse number: {}", e),
FailedGlobPattern(ref e) => write!(f, "Failed to parse glob pattern: {}", e),
}

1
xtests/error_duplicate Normal file
View File

@ -0,0 +1 @@
Flag -l conflicts with flag --long

1
xtests/error_twice Normal file
View File

@ -0,0 +1 @@
Flag -l was given twice

View File

@ -1 +1 @@
Option --binary (-b) is useless without option --long (-l).
Option --binary (-b) is useless without option --long (-l)

View File

@ -189,6 +189,8 @@ $exa --ternary 2>&1 | diff -q - $results/error_long || exit 1
$exa -4 2>&1 | diff -q - $results/error_short || exit 1
$exa --time 2>&1 | diff -q - $results/error_value || exit 1
$exa --long=time 2>&1 | diff -q - $results/error_overvalued || exit 1
$exa -l --long 2>&1 | diff -q - $results/error_duplicate || exit 1
$exa -ll 2>&1 | diff -q - $results/error_twice || exit 1
# Debug mode