Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message when compressing folder with single-file formats #303

Conversation

marcospb19
Copy link
Member

Closes #268.

Before this PR:

$ ouch compress empty-folder file.gz.xz.bz
[ERROR] failed to read from file `/home/marcospb19/empty-folder`

After the PR:

$ ouch compress empty-folder file.gz.xz.bz
[ERROR] Cannot compress to 'file.gz.xz.bz'.
 - You are trying to compress a folder.
 - The compression format 'gz' does not accept multiple files.
 - Formats that bundle files into an archive are .tar and .zip.

hint: Try inserting '.tar' or '.zip' before 'gz'.
hint: From: file.gz.xz.bz
hint: To:   file.tar.gz.xz.bz

Copy link
Member

@figsoda figsoda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@figsoda figsoda merged commit dcd2257 into main Oct 17, 2022
@figsoda figsoda deleted the improve-error-message-when-compressing-folder-with-single-file-format branch October 17, 2022 14:32
@@ -89,28 +89,24 @@ pub fn run(
// Formats from path extension, like "file.tar.gz.xz" -> vec![Tar, Gzip, Lzma]
let formats = extension::extensions_from_path(&output_path);

if formats.is_empty() {
let error = FinalError::with_title(format!("Cannot compress to '{}'.", to_utf(&output_path)))
let first_format = formats.first().ok_or_else(|| {
Copy link
Member Author

@marcospb19 marcospb19 Oct 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve error message description when trying to compress a folder with a multiple single file formats
2 participants