Skip to content

Confusing behavior when listing archive contents of unrecognized file extension #945

@FichteFoll

Description

@FichteFoll

When listing the contents of a *.sublime-package file, which is a zip file with a different extension, ouch shows a warning that it is about to "uncompress" the provided file. Additionally, it prints a warning.

Example:

~/.config/sublime-text/Installed Packages $ ouch l --tree AdvancedNewFile.sublime-package
[WARNING] We detected a file named `/home/fichte/.config/sublime-text/Installed Packages/AdvancedNewFile.sublime-package`, do you want to decompress it?
Do you want to decompress 'AdvancedNewFile.sublime-package'? [Y/n]

There are several confusing things about this:

  1. It re-prints the full path of the file I want to list in a "matter of fact" way and prefixes it as a warning. It should tell me why it thinks this is worth warning about, i.e. because it could not infer the file format from its extension.
  2. It should not ask me whether I want to "decompress" the file when I actually just want to list its contents. I was wondering whether I used the wrong command.
  3. When I press Y (or pass -y as an argument), it lists the file contents without complaints, so it was able to determine what format the file is in but decided to warn me about it anyway? Note that the warning is still printed when I pass -y as an argument but it provides no useful information to me because outside of the warning it works as I would expect.
  4. None of this happens when I explicitly provide the format via -f zip.

In summary, I propose the following changes:

  1. Detect the archive type of the provided file.
  2. Only print the warning if the file type could not be inferred at all.
  3. When not invoked with -y, include the detected format in the question.
  4. Do not use the term "decompress" in the question when listing.

Proposal example:

~/.config/sublime-text/Installed Packages $ ouch l --tree AdvancedNewFile.sublime-package
[INFO] Inferred file type 'zip' for 'AdvancedNewFile.sublime-package'.
Do you want to read 'AdvancedNewFile.sublime-package' using the zip format? [Y/n]

I added an info line here. I did not confirm this, but I would expect the info line to not be printed when --quiet is passed to prevent this from polluting the output when invoked via other means, e.g. https://github.com/ndtoan96/ouch.yazi.

  • ouch version: 0.6.1
  • OS: Arch Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions