mirror of
https://github.com/eza-community/eza
synced 2024-10-04 15:09:49 +00:00
use match for timeformat-parsing
This commit is contained in:
parent
4911ac6714
commit
1b54874ce8
|
@ -14,7 +14,7 @@ pub enum OptionsError {
|
|||
Parse(ParseError),
|
||||
|
||||
/// The user supplied an illegal choice to an Argument.
|
||||
BadArgument(&'static Arg, OsString),
|
||||
BadArgument(&'static Arg, String),
|
||||
|
||||
/// The user supplied a set of options that are unsupported
|
||||
Unsupported(String),
|
||||
|
|
|
@ -254,23 +254,14 @@ impl TimeFormat {
|
|||
}
|
||||
};
|
||||
|
||||
if &word == "default" {
|
||||
Ok(Self::DefaultFormat)
|
||||
}
|
||||
else if &word == "relative" {
|
||||
Ok(Self::Relative)
|
||||
}
|
||||
else if &word == "iso" {
|
||||
Ok(Self::ISOFormat)
|
||||
}
|
||||
else if &word == "long-iso" {
|
||||
Ok(Self::LongISO)
|
||||
}
|
||||
else if &word == "full-iso" {
|
||||
Ok(Self::FullISO)
|
||||
}
|
||||
else {
|
||||
Err(OptionsError::BadArgument(&flags::TIME_STYLE, word))
|
||||
let word = word.to_string_lossy();
|
||||
match word.as_ref() {
|
||||
"default" => Ok(Self::DefaultFormat),
|
||||
"relative" => Ok(Self::Relative),
|
||||
"iso" => Ok(Self::ISOFormat),
|
||||
"long-iso" => Ok(Self::LongISO),
|
||||
"full-iso" => Ok(Self::FullISO),
|
||||
_ => Err(OptionsError::BadArgument(&flags::TIME_STYLE, word.to_string()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue