mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-06 11:35:45 +00:00
Enable nightly for unstable fmt feature and run cargo fmt
This commit is contained in:
parent
702e7622db
commit
c44cdf1013
1
rust-toolchain
Normal file
1
rust-toolchain
Normal file
@ -0,0 +1 @@
|
|||||||
|
nightly
|
@ -6,3 +6,5 @@ reorder_imports = true
|
|||||||
reorder_modules = true
|
reorder_modules = true
|
||||||
use_try_shorthand = true
|
use_try_shorthand = true
|
||||||
use_small_heuristics = "Max"
|
use_small_heuristics = "Max"
|
||||||
|
unstable_features = true
|
||||||
|
force_multiline_blocks = true
|
||||||
|
54
src/error.rs
54
src/error.rs
@ -103,31 +103,39 @@ impl fmt::Display for Error {
|
|||||||
.detail("This is unadvisable since ouch does compressions in-memory.")
|
.detail("This is unadvisable since ouch does compressions in-memory.")
|
||||||
.hint("Use a more appropriate tool for this, such as rsync.")
|
.hint("Use a more appropriate tool for this, such as rsync.")
|
||||||
}
|
}
|
||||||
Error::MissingArgumentsForCompression => FinalError::with_title("Could not compress")
|
Error::MissingArgumentsForCompression => {
|
||||||
.detail("The compress command requires at least 2 arguments")
|
FinalError::with_title("Could not compress")
|
||||||
.hint("You must provide:")
|
.detail("The compress command requires at least 2 arguments")
|
||||||
.hint(" - At least one input argument.")
|
.hint("You must provide:")
|
||||||
.hint(" - The output argument.")
|
.hint(" - At least one input argument.")
|
||||||
.hint("")
|
.hint(" - The output argument.")
|
||||||
.hint("Example: `ouch compress image.png img.zip`"),
|
.hint("")
|
||||||
Error::MissingArgumentsForDecompression => FinalError::with_title("Could not decompress")
|
.hint("Example: `ouch compress image.png img.zip`")
|
||||||
.detail("The compress command requires at least one argument")
|
}
|
||||||
.hint("You must provide:")
|
Error::MissingArgumentsForDecompression => {
|
||||||
.hint(" - At least one input argument.")
|
FinalError::with_title("Could not decompress")
|
||||||
.hint("")
|
.detail("The compress command requires at least one argument")
|
||||||
.hint("Example: `ouch decompress imgs.tar.gz`"),
|
.hint("You must provide:")
|
||||||
Error::InternalError => FinalError::with_title("InternalError :(")
|
.hint(" - At least one input argument.")
|
||||||
.detail("This should not have happened")
|
.hint("")
|
||||||
.detail("It's probably our fault")
|
.hint("Example: `ouch decompress imgs.tar.gz`")
|
||||||
.detail("Please help us improve by reporting the issue at:")
|
}
|
||||||
.detail(format!(" {}https://github.com/vrmiguel/ouch/issues ", cyan())),
|
Error::InternalError => {
|
||||||
|
FinalError::with_title("InternalError :(")
|
||||||
|
.detail("This should not have happened")
|
||||||
|
.detail("It's probably our fault")
|
||||||
|
.detail("Please help us improve by reporting the issue at:")
|
||||||
|
.detail(format!(" {}https://github.com/vrmiguel/ouch/issues ", cyan()))
|
||||||
|
}
|
||||||
Error::OofError(err) => FinalError::with_title(err),
|
Error::OofError(err) => FinalError::with_title(err),
|
||||||
Error::IoError { reason } => FinalError::with_title(reason),
|
Error::IoError { reason } => FinalError::with_title(reason),
|
||||||
Error::CompressionTypo => FinalError::with_title("Possible typo detected").hint(format!(
|
Error::CompressionTypo => {
|
||||||
"Did you mean '{}ouch compress{}'?",
|
FinalError::with_title("Possible typo detected").hint(format!(
|
||||||
magenta(),
|
"Did you mean '{}ouch compress{}'?",
|
||||||
reset()
|
magenta(),
|
||||||
)),
|
reset()
|
||||||
|
))
|
||||||
|
}
|
||||||
Error::UnknownExtensionError(_) => todo!(),
|
Error::UnknownExtensionError(_) => todo!(),
|
||||||
Error::AlreadyExists => todo!(),
|
Error::AlreadyExists => todo!(),
|
||||||
Error::InvalidZipArchive(_) => todo!(),
|
Error::InvalidZipArchive(_) => todo!(),
|
||||||
|
@ -31,18 +31,22 @@ impl fmt::Display for OofError {
|
|||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
// TODO: implement proper debug messages
|
// TODO: implement proper debug messages
|
||||||
match self {
|
match self {
|
||||||
OofError::FlagValueConflict { flag, previous_value, new_value } => write!(
|
OofError::FlagValueConflict { flag, previous_value, new_value } => {
|
||||||
f,
|
write!(
|
||||||
"CLI flag value conflicted for flag '--{}', previous: {:?}, new: {:?}.",
|
f,
|
||||||
flag.long, previous_value, new_value
|
"CLI flag value conflicted for flag '--{}', previous: {:?}, new: {:?}.",
|
||||||
),
|
flag.long, previous_value, new_value
|
||||||
|
)
|
||||||
|
}
|
||||||
OofError::InvalidUnicode(flag) => write!(f, "{:?} is not valid Unicode.", flag),
|
OofError::InvalidUnicode(flag) => write!(f, "{:?} is not valid Unicode.", flag),
|
||||||
OofError::UnknownShortFlag(ch) => write!(f, "Unknown argument '-{}'", ch),
|
OofError::UnknownShortFlag(ch) => write!(f, "Unknown argument '-{}'", ch),
|
||||||
OofError::MisplacedShortArgFlagError(ch) => write!(
|
OofError::MisplacedShortArgFlagError(ch) => {
|
||||||
f,
|
write!(
|
||||||
"Invalid placement of `-{}`.\nOnly the last letter in a sequence of short flags can take values.",
|
f,
|
||||||
ch
|
"Invalid placement of `-{}`.\nOnly the last letter in a sequence of short flags can take values.",
|
||||||
),
|
ch
|
||||||
|
)
|
||||||
|
}
|
||||||
OofError::MissingValueToFlag(flag) => write!(f, "Flag {} takes value but none was supplied.", flag),
|
OofError::MissingValueToFlag(flag) => write!(f, "Flag {} takes value but none was supplied.", flag),
|
||||||
OofError::DuplicatedFlag(flag) => write!(f, "Duplicated usage of {}.", flag),
|
OofError::DuplicatedFlag(flag) => write!(f, "Duplicated usage of {}.", flag),
|
||||||
OofError::UnknownLongFlag(flag) => write!(f, "Unknown argument '--{}'", flag),
|
OofError::UnknownLongFlag(flag) => write!(f, "Unknown argument '--{}'", flag),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user