mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-31 21:17:46 +00:00
seq: use usage error where appropriate
This commit is contained in:
parent
d894847fc6
commit
a3e6d2b84b
1 changed files with 9 additions and 11 deletions
|
@ -31,20 +31,20 @@ impl SeqError {
|
||||||
/// The [`String`] argument as read from the command-line.
|
/// The [`String`] argument as read from the command-line.
|
||||||
fn arg(&self) -> &str {
|
fn arg(&self) -> &str {
|
||||||
match self {
|
match self {
|
||||||
SeqError::ParseError(s, _) => s,
|
Self::ParseError(s, _) => s,
|
||||||
SeqError::ZeroIncrement(s) => s,
|
Self::ZeroIncrement(s) => s,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The type of argument that is causing the error.
|
/// The type of argument that is causing the error.
|
||||||
fn argtype(&self) -> &str {
|
fn argtype(&self) -> &str {
|
||||||
match self {
|
match self {
|
||||||
SeqError::ParseError(_, e) => match e {
|
Self::ParseError(_, e) => match e {
|
||||||
ParseNumberError::Float => "floating point argument",
|
ParseNumberError::Float => "floating point argument",
|
||||||
ParseNumberError::Nan => "'not-a-number' argument",
|
ParseNumberError::Nan => "'not-a-number' argument",
|
||||||
ParseNumberError::Hex => "hexadecimal argument",
|
ParseNumberError::Hex => "hexadecimal argument",
|
||||||
},
|
},
|
||||||
SeqError::ZeroIncrement(_) => "Zero increment value",
|
Self::ZeroIncrement(_) => "Zero increment value",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,18 +53,16 @@ impl UError for SeqError {
|
||||||
fn code(&self) -> i32 {
|
fn code(&self) -> i32 {
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn usage(&self) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Error for SeqError {}
|
impl Error for SeqError {}
|
||||||
|
|
||||||
impl Display for SeqError {
|
impl Display for SeqError {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
write!(
|
write!(f, "invalid {}: {}", self.argtype(), self.arg().quote())
|
||||||
f,
|
|
||||||
"invalid {}: {}\nTry '{} --help' for more information.",
|
|
||||||
self.argtype(),
|
|
||||||
self.arg().quote(),
|
|
||||||
uucore::execution_phrase(),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue