mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-06 11:35:45 +00:00
apply clippy suggestions
This commit is contained in:
parent
b66932b5fb
commit
e06b2c8635
@ -140,7 +140,7 @@ where
|
||||
builder.append_file(path, file.file_mut()).map_err(|err| {
|
||||
FinalError::with_title("Could not create archive")
|
||||
.detail("Unexpected error while trying to read file")
|
||||
.detail(format!("Error: {}.", err))
|
||||
.detail(format!("Error: {err}."))
|
||||
})?;
|
||||
}
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ pub fn run(
|
||||
"You are trying to compress a folder."
|
||||
};
|
||||
|
||||
let error = FinalError::with_title(format!("Cannot compress to '{}'.", output_path))
|
||||
let error = FinalError::with_title(format!("Cannot compress to '{output_path}'."))
|
||||
.detail(first_detail_message)
|
||||
.detail(format!(
|
||||
"The compression format '{}' does not accept multiple files.",
|
||||
@ -154,8 +154,8 @@ pub fn run(
|
||||
))
|
||||
.detail("Formats that bundle files into an archive are .tar and .zip.")
|
||||
.hint(format!("Try inserting '.tar' or '.zip' before '{}'.", &formats[0]))
|
||||
.hint(format!("From: {}", output_path))
|
||||
.hint(format!("To: {}", suggested_output_path));
|
||||
.hint(format!("From: {output_path}"))
|
||||
.hint(format!("To: {suggested_output_path}"));
|
||||
|
||||
return Err(error.into());
|
||||
}
|
||||
@ -165,14 +165,12 @@ pub fn run(
|
||||
"Cannot compress to '{}'.",
|
||||
EscapedPathDisplay::new(&output_path)
|
||||
))
|
||||
.detail(format!("Found the format '{}' in an incorrect position.", format))
|
||||
.detail(format!("Found the format '{format}' in an incorrect position."))
|
||||
.detail(format!(
|
||||
"'{}' can only be used at the start of the file extension.",
|
||||
format
|
||||
"'{format}' can only be used at the start of the file extension."
|
||||
))
|
||||
.hint(format!(
|
||||
"If you wish to compress multiple files, start the extension with '{}'.",
|
||||
format
|
||||
"If you wish to compress multiple files, start the extension with '{format}'."
|
||||
))
|
||||
.hint(format!(
|
||||
"Otherwise, remove the last '{}' from '{}'.",
|
||||
|
@ -76,7 +76,7 @@ impl Display for FinalError {
|
||||
if is_running_in_accessible_mode() {
|
||||
write!(f, "\n{}hints:{}", *GREEN, *RESET)?;
|
||||
for hint in &self.hints {
|
||||
write!(f, "\n{}", hint)?;
|
||||
write!(f, "\n{hint}")?;
|
||||
}
|
||||
} else {
|
||||
for hint in &self.hints {
|
||||
@ -138,7 +138,7 @@ impl fmt::Display for Error {
|
||||
Error::Custom { reason } => reason.clone(),
|
||||
};
|
||||
|
||||
write!(f, "{}", err)
|
||||
write!(f, "{err}")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ fn print_entry(name: impl std::fmt::Display, is_dir: bool) {
|
||||
if is_dir {
|
||||
// if colors are deactivated, print final / to mark directories
|
||||
if BLUE.is_empty() {
|
||||
println!("{}/", name);
|
||||
println!("{name}/");
|
||||
// if in ACCESSIBLE mode, use colors but print final / in case colors
|
||||
// aren't read out aloud with a screen reader or aren't printed on a
|
||||
// braille reader
|
||||
@ -68,7 +68,7 @@ fn print_entry(name: impl std::fmt::Display, is_dir: bool) {
|
||||
}
|
||||
} else {
|
||||
// not a dir -> just print the file name
|
||||
println!("{}", name);
|
||||
println!("{name}");
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,7 +142,7 @@ mod tree {
|
||||
false => draw::FINAL_BRANCH,
|
||||
};
|
||||
|
||||
print!("{}{}", prefix, final_part);
|
||||
print!("{prefix}{final_part}");
|
||||
let is_dir = match self.file {
|
||||
Some(FileInArchive { is_dir, .. }) => is_dir,
|
||||
None => true,
|
||||
|
@ -31,7 +31,7 @@ pub const EXIT_FAILURE: i32 = libc::EXIT_FAILURE;
|
||||
|
||||
fn main() {
|
||||
if let Err(err) = run() {
|
||||
eprintln!("{}", err);
|
||||
eprintln!("{err}");
|
||||
std::process::exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ impl Display for EscapedPathDisplay<'_> {
|
||||
|
||||
let bstr = bstr::BStr::new(self.path.as_os_str().as_bytes());
|
||||
|
||||
write!(f, "{}", bstr)
|
||||
write!(f, "{bstr}")
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ impl Display for EscapedPathDisplay<'_> {
|
||||
/// See <https://gist.github.com/marcospb19/ebce5572be26397cf08bbd0fd3b65ac1> for a comparison.
|
||||
pub fn to_utf(os_str: &Path) -> Cow<str> {
|
||||
let format = || {
|
||||
let text = format!("{:?}", os_str);
|
||||
let text = format!("{os_str:?}");
|
||||
Cow::Owned(text.trim_matches('"').to_string())
|
||||
};
|
||||
|
||||
|
@ -86,7 +86,7 @@ pub fn user_wants_to_continue(
|
||||
let path = to_utf(strip_cur_dir(path));
|
||||
let path = Some(&*path);
|
||||
let placeholder = Some("FILE");
|
||||
Confirmation::new(&format!("Do you want to {} 'FILE'?", action), placeholder).ask(path)
|
||||
Confirmation::new(&format!("Do you want to {action} 'FILE'?"), placeholder).ask(path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user