mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-11-25 21:37:33 +00:00
Add actual error messages for the error messages
The annoying part is trying to format!() an OsStr.
This commit is contained in:
parent
adaa36e1c5
commit
b286676667
@ -92,7 +92,7 @@ impl fmt::Display for Misfire {
|
|||||||
|
|
||||||
match *self {
|
match *self {
|
||||||
BadArgument(ref a, ref b, ref c) => write!(f, "Option {} has no value {:?} (Choices: {})", a, b, c),
|
BadArgument(ref a, ref b, ref c) => write!(f, "Option {} has no value {:?} (Choices: {})", a, b, c),
|
||||||
InvalidOptions(ref e) => write!(f, "{:?}", e),
|
InvalidOptions(ref e) => write!(f, "{}", e),
|
||||||
Help(ref text) => write!(f, "{}", text),
|
Help(ref text) => write!(f, "{}", text),
|
||||||
Version(ref version) => write!(f, "{}", version),
|
Version(ref version) => write!(f, "{}", version),
|
||||||
Conflict(ref a, ref b) => write!(f, "Option {} conflicts with option {}.", a, b),
|
Conflict(ref a, ref b) => write!(f, "Option {} conflicts with option {}.", a, b),
|
||||||
@ -106,3 +106,16 @@ impl fmt::Display for Misfire {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for ParseError {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
use self::ParseError::*;
|
||||||
|
|
||||||
|
match *self {
|
||||||
|
NeedsValue { ref flag } => write!(f, "Flag {} needs a value", flag),
|
||||||
|
ForbiddenValue { ref flag } => write!(f, "Flag {} cannot take a value", flag),
|
||||||
|
UnknownShortArgument { ref attempt } => write!(f, "Unknown argument -{}", *attempt as char),
|
||||||
|
UnknownArgument { ref attempt } => write!(f, "Unknown argument --{}", attempt.to_string_lossy()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -60,6 +60,14 @@ impl Flag {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for Flag {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
||||||
|
match *self {
|
||||||
|
Flag::Short(short) => write!(f, "-{}", short as char),
|
||||||
|
Flag::Long(long) => write!(f, "--{}", long),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Whether redundant arguments should be considered a problem.
|
/// Whether redundant arguments should be considered a problem.
|
||||||
#[derive(PartialEq, Debug, Copy, Clone)]
|
#[derive(PartialEq, Debug, Copy, Clone)]
|
||||||
|
1
xtests/error_long
Normal file
1
xtests/error_long
Normal file
@ -0,0 +1 @@
|
|||||||
|
Unknown argument --ternary
|
1
xtests/error_overvalued
Normal file
1
xtests/error_overvalued
Normal file
@ -0,0 +1 @@
|
|||||||
|
Flag --long cannot take a value
|
1
xtests/error_short
Normal file
1
xtests/error_short
Normal file
@ -0,0 +1 @@
|
|||||||
|
Unknown argument -4
|
1
xtests/error_value
Normal file
1
xtests/error_value
Normal file
@ -0,0 +1 @@
|
|||||||
|
Flag --time needs a value
|
@ -178,7 +178,11 @@ $exa $testcases/hiddens -l -aa 2>&1 | diff -q - $results/hiddens_laa || exit 1
|
|||||||
|
|
||||||
|
|
||||||
# Errors
|
# Errors
|
||||||
$exa --binary 2>&1 | diff -q - $results/errors_useless || exit 1
|
$exa --binary 2>&1 | diff -q - $results/error_useless || exit 1
|
||||||
|
$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
|
||||||
|
|
||||||
|
|
||||||
# And finally...
|
# And finally...
|
||||||
|
Loading…
Reference in New Issue
Block a user