ouch-org / ouch

Painless compression and decompression in the terminal
https://crates.io/crates/ouch
Other
2.25k stars 76 forks source link

Support `.7z` #164

Closed BLucky-gh closed 11 months ago

BLucky-gh commented 2 years ago

The title sums up the first part of the request pretty well, 7z is a pretty popular archive format, but 7z supports several different compression formats it supports, so I think it would also be good to add an option like --format/-f to specify a compression format independently of the file name, which would be useful in general too

marcospb19 commented 2 years ago

About --format, it's related to #134.

(I think this issue can focus more on 7z.)

figsoda commented 2 years ago

The only crate I found is https://lib.rs/crates/rust7z, docs are failing and seems unmaintained https://lib.rs/crates/lzma-rs does say it might also implement 7z in the future, its something we can wait for otherwise we would have to implement it ourselves using some lzma crate

marcospb19 commented 2 years ago

I'd rather wait for other crates than implement it by ourselves (unless someone gets really interested in doing so...), Rust ecosystem is always growing, so I bet that someone will do it (from scratch or by fixing existing crates).

Will keep this open indefinitely, in hope it will become possible.

siph commented 2 years ago

https://crates.io/crates/sevenz-rust may be worth watching. Doesn't look like it supports compression yet.

blooalien commented 1 year ago

Can you not maybe rely upon and call out to the 7z/7z.exe shell command for 7z functionality perhaps? I believe 7z also supports RAR archives as well, so that would give you a free solution to the "Support RAR" issue request as well, I think. Or is that sorta thing not very convenient to do from Rust? (I'ma Python guy, so I'm afraid I know little about Rust beyond how to build / install existing Rust apps. On Python, I use the subprocess library to call shell commands. I just kinda assumed most modern languages have similar functionality available.)

marcospb19 commented 1 year ago

Calling a binary works, but it can make shipping more difficult, currently Ouch does not require any other binary to be installed, but there are a couple of alternative tools that approach it this way. We'd need to put this as a dependency, but then Ouch wouldn't be shippable to something that 7z isn't shipped too.

Invoking a binary also runs into some other problems I explained in finer detail at #152, regarding stream encoding and decoding, and also error handling, I think that error treatment in Ouch is very satisfactory, we can generate a custom message for almost all steps.

When I consider all of these I'd say it's not worth it, but it's open for discussion, we might want to take the trade-offs and additional implementation trouble.

Aziks0 commented 1 year ago

https://crates.io/crates/sevenz-rust supports compression since version 0.2.0.

marcospb19 commented 1 year ago

@Aziks0 thanks for pointing this out, I labeled this issue as "good first issue" in case someone wants to take it.