mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-30 04:27:45 +00:00
Merge pull request #3539 from jfinkels/seq-usage-error
seq: use usage error where appropriate
This commit is contained in:
commit
ae7d8aac46
1 changed files with 9 additions and 11 deletions
|
@ -31,20 +31,20 @@ impl SeqError {
|
|||
/// The [`String`] argument as read from the command-line.
|
||||
fn arg(&self) -> &str {
|
||||
match self {
|
||||
SeqError::ParseError(s, _) => s,
|
||||
SeqError::ZeroIncrement(s) => s,
|
||||
Self::ParseError(s, _) => s,
|
||||
Self::ZeroIncrement(s) => s,
|
||||
}
|
||||
}
|
||||
|
||||
/// The type of argument that is causing the error.
|
||||
fn argtype(&self) -> &str {
|
||||
match self {
|
||||
SeqError::ParseError(_, e) => match e {
|
||||
Self::ParseError(_, e) => match e {
|
||||
ParseNumberError::Float => "floating point argument",
|
||||
ParseNumberError::Nan => "'not-a-number' 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 {
|
||||
1
|
||||
}
|
||||
|
||||
fn usage(&self) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
impl Error for SeqError {}
|
||||
|
||||
impl Display for SeqError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"invalid {}: {}\nTry '{} --help' for more information.",
|
||||
self.argtype(),
|
||||
self.arg().quote(),
|
||||
uucore::execution_phrase(),
|
||||
)
|
||||
write!(f, "invalid {}: {}", self.argtype(), self.arg().quote())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue