Use the new method were applicable

This commit is contained in:
Spyros Roum 2021-10-22 02:04:08 +03:00
parent 340827de1f
commit 0f3bc4f444

View File

@ -56,7 +56,9 @@ pub fn run(args: Opts, skip_questions_positively: Option<bool>) -> crate::Result
return Err(Error::with_reason(reason)); return Err(Error::with_reason(reason));
} }
if matches!(&formats[0], Bzip | Gzip | Lzma) && represents_several_files(&files) { if !formats.get(0).map(CompressionFormat::is_archive_format).unwrap_or(false)
&& represents_several_files(&files)
{
// This piece of code creates a suggestion for compressing multiple files // This piece of code creates a suggestion for compressing multiple files
// It says: // It says:
// Change from file.bz.xz // Change from file.bz.xz
@ -84,7 +86,7 @@ pub fn run(args: Opts, skip_questions_positively: Option<bool>) -> crate::Result
return Err(Error::with_reason(reason)); return Err(Error::with_reason(reason));
} }
if let Some(format) = formats.iter().skip(1).find(|format| matches!(format, Tar | Zip)) { if let Some(format) = formats.iter().skip(1).find(|format| format.is_archive_format()) {
let reason = FinalError::with_title(format!("Cannot compress to '{}'.", to_utf(&output_path))) 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!("Found the format '{}' in an incorrect position.", format))
.detail(format!("'{}' can only be used at the start of the file extension.", format)) .detail(format!("'{}' can only be used at the start of the file extension.", format))