mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-07 12:05:46 +00:00
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`.
This commit is contained in:
parent
f46ff3c26e
commit
d6327a00e8
@ -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));
|
||||
|
Loading…
x
Reference in New Issue
Block a user