From d6327a00e8637ebac13b58a00a74120c89f1a972 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Fri, 8 Oct 2021 07:11:36 +0200 Subject: [PATCH] chore: print format type instead of index When it raises an error caused by position of the format, now prints the format type as string instead of the position inside the array of formats. In this way you can read on stdout the type like `.tar` or `.lz` instead of `1`, `2`, .., `n`. --- src/commands.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index bf278b6..df70a76 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -85,12 +85,12 @@ pub fn run(command: Command, flags: &oof::Flags) -> crate::Result<()> { return Err(Error::with_reason(reason)); } - if let Some(format) = formats.iter().skip(1).position(|format| matches!(format, Tar | Zip)) { + if let Some(format) = formats.iter().skip(1).find(|format| matches!(format, Tar | Zip)) { let reason = FinalError::with_title(format!("Cannot compress to '{}'.", to_utf(&output_path))) .detail(format!("Found the format '{}' in an incorrect position.", format)) - .detail(format!("{} can only be used at the start of the file extension.", format)) - .hint(format!("If you wish to compress multiple files, start the extension with {}.", format)) - .hint(format!("Otherwise, remove {} from '{}'.", format, to_utf(&output_path))) + .detail(format!("'{}' can only be used at the start of the file extension.", format)) + .hint(format!("If you wish to compress multiple files, start the extension with '{}'.", format)) + .hint(format!("Otherwise, remove the last '{}' from '{}'.", format, to_utf(&output_path))) .into_owned(); return Err(Error::with_reason(reason));