Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/archive/tar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}."))
})?;
}
}
Expand Down
23 changes: 10 additions & 13 deletions src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,15 @@ 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.",
&formats[0]
"The compression format '{first_format}' does not accept multiple files.",
))
.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!("Try inserting '.tar' or '.zip' before '{first_format}'."))
.hint(format!("From: {output_path}"))
.hint(format!("To: {suggested_output_path}"));

return Err(error.into());
}
Expand All @@ -165,14 +164,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 '{}'.",
Expand Down Expand Up @@ -247,7 +244,7 @@ pub fn run(
.map(|(input_path, _)| PathBuf::from(input_path))
.collect();

if !files_missing_format.is_empty() {
if let Some(path) = files_missing_format.first() {
let error = FinalError::with_title("Cannot decompress files without extensions")
.detail(format!(
"Files without supported extensions: {}",
Expand All @@ -260,7 +257,7 @@ pub fn run(
.hint("Or overwrite this option with the '--format' flag:")
.hint(format!(
" ouch decompress {} --format tar.gz",
to_utf(&files_missing_format[0])
EscapedPathDisplay::new(path),
));

return Err(error.into());
Expand Down
4 changes: 2 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -138,7 +138,7 @@ impl fmt::Display for Error {
Error::Custom { reason } => reason.clone(),
};

write!(f, "{}", err)
write!(f, "{err}")
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}");
}
}

Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/formatting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
}
}

Expand All @@ -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())
};

Expand Down
2 changes: 1 addition & 1 deletion src/utils/question.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down