From 93752d5fb5f343e92c9dd23da44104777b1d28f9 Mon Sep 17 00:00:00 2001 From: Antonios Barotsis Date: Mon, 11 Mar 2024 21:24:45 +0100 Subject: [PATCH] fmt --- src/archive/zip.rs | 13 ++++++------- src/check.rs | 22 ++++++++++++---------- src/commands/compress.rs | 2 +- src/commands/mod.rs | 9 ++++++--- 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/archive/zip.rs b/src/archive/zip.rs index 9fcd3d5..0439c6e 100644 --- a/src/archive/zip.rs +++ b/src/archive/zip.rs @@ -20,7 +20,8 @@ use crate::{ error::FinalError, list::FileInArchive, utils::{ - self, cd_into_same_dir_as, get_invalid_utf8_paths, message::PrintMessage, pretty_format_list_of_paths, strip_cur_dir, Bytes, EscapedPathDisplay, FileVisibilityPolicy + self, cd_into_same_dir_as, get_invalid_utf8_paths, message::PrintMessage, pretty_format_list_of_paths, + strip_cur_dir, Bytes, EscapedPathDisplay, FileVisibilityPolicy, }, warning, }; @@ -145,7 +146,7 @@ pub fn build_archive_from_paths( writer: W, file_visibility_policy: FileVisibilityPolicy, quiet: bool, - log_sender: Sender + log_sender: Sender, ) -> crate::Result where W: Write + Seek, @@ -202,12 +203,10 @@ where if !quiet { log_sender .send(PrintMessage { - contents: format!( - "Compressing '{}'.", - EscapedPathDisplay::new(path) - ), + contents: format!("Compressing '{}'.", EscapedPathDisplay::new(path)), accessible: false, - }).unwrap(); + }) + .unwrap(); } let metadata = match path.metadata() { diff --git a/src/check.rs b/src/check.rs index 609bbfc..0145466 100644 --- a/src/check.rs +++ b/src/check.rs @@ -5,13 +5,17 @@ use std::{ ffi::OsString, ops::ControlFlow, - path::{Path, PathBuf}, sync::mpsc::Sender, + path::{Path, PathBuf}, + sync::mpsc::Sender, }; use crate::{ error::FinalError, extension::{build_archive_file_suggestion, Extension, PRETTY_SUPPORTED_ALIASES, PRETTY_SUPPORTED_EXTENSIONS}, - utils::{message::PrintMessage, pretty_format_list_of_paths, try_infer_extension, user_wants_to_continue, EscapedPathDisplay}, + utils::{ + message::PrintMessage, pretty_format_list_of_paths, try_infer_extension, user_wants_to_continue, + EscapedPathDisplay, + }, warning, QuestionAction, QuestionPolicy, Result, }; @@ -25,7 +29,7 @@ pub fn check_mime_type( path: &Path, formats: &mut Vec, question_policy: QuestionPolicy, - log_sender: Sender + log_sender: Sender, ) -> Result> { if formats.is_empty() { // File with no extension @@ -35,13 +39,10 @@ pub fn check_mime_type( // mistyped, ...) which we should always inform the user about. log_sender .send(PrintMessage { - contents: format!( - "Detected file: `{}` extension as `{}`", - path.display(), - detected_format - ), + contents: format!("Detected file: `{}` extension as `{}`", path.display(), detected_format), accessible: true, - }).unwrap(); + }) + .unwrap(); if user_wants_to_continue(path, question_policy, QuestionAction::Decompression)? { formats.push(detected_format); } else { @@ -76,7 +77,8 @@ pub fn check_mime_type( path.display() ), accessible: true, - }).unwrap(); + }) + .unwrap(); } Ok(ControlFlow::Continue(())) } diff --git a/src/commands/compress.rs b/src/commands/compress.rs index 3ec03bf..ee02981 100644 --- a/src/commands/compress.rs +++ b/src/commands/compress.rs @@ -128,7 +128,7 @@ pub fn compress_files( &mut vec_buffer, file_visibility_policy, quiet, - log_sender.clone() + log_sender.clone(), )?; vec_buffer.rewind()?; io::copy(&mut vec_buffer, &mut writer)?; diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 513314c..423c75a 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -19,7 +19,6 @@ use crate::{ commands::{compress::compress_files, decompress::decompress_file, list::list_archive_contents}, error::{Error, FinalError}, extension::{self, parse_format}, - info, list::ListOptions, utils::{self, message::PrintMessage, to_utf, EscapedPathDisplay, FileVisibilityPolicy}, warning, CliArgs, QuestionPolicy, @@ -198,7 +197,9 @@ pub fn run( for path in files.iter() { let (pathbase, mut file_formats) = extension::separate_known_extensions_from_name(path); - if let ControlFlow::Break(_) = check::check_mime_type(path, &mut file_formats, question_policy, log_sender.clone())? { + if let ControlFlow::Break(_) = + check::check_mime_type(path, &mut file_formats, question_policy, log_sender.clone())? + { return Ok(()); } @@ -247,7 +248,9 @@ pub fn run( for path in files.iter() { let mut file_formats = extension::extensions_from_path(path); - if let ControlFlow::Break(_) = check::check_mime_type(path, &mut file_formats, question_policy, log_sender.clone())? { + if let ControlFlow::Break(_) = + check::check_mime_type(path, &mut file_formats, question_policy, log_sender.clone())? + { return Ok(()); }