Add zstd (and tzstd) alias

This commit is contained in:
Antonios Barotsis 2024-01-26 10:26:11 +01:00
parent 49e2481d06
commit 86dd5880e9
8 changed files with 13 additions and 12 deletions

View File

@ -23,14 +23,14 @@ pub const SUPPORTED_EXTENSIONS: &[&str] = &[
"7z",
];
pub const SUPPORTED_ALIASES: &[&str] = &["tgz", "tbz", "tlz4", "txz", "tzlma", "tsz", "tzst"];
pub const SUPPORTED_ALIASES: &[&str] = &["tgz", "tbz", "tlz4", "txz", "tzlma", "tsz", "tzst", "zstd", "tzstd"];
#[cfg(not(feature = "unrar"))]
pub const PRETTY_SUPPORTED_EXTENSIONS: &str = "tar, zip, bz, bz2, gz, lz4, xz, lzma, sz, zst, 7z";
#[cfg(feature = "unrar")]
pub const PRETTY_SUPPORTED_EXTENSIONS: &str = "tar, zip, bz, bz2, gz, lz4, xz, lzma, sz, zst, rar, 7z";
pub const PRETTY_SUPPORTED_ALIASES: &str = "tgz, tbz, tlz4, txz, tzlma, tsz, tzst";
pub const PRETTY_SUPPORTED_ALIASES: &str = "tgz, tbz, tlz4, txz, tzlma, tsz, tzst, zstd, tzstd";
/// A wrapper around `CompressionFormat` that allows combinations like `tgz`
#[derive(Debug, Clone, Eq)]
@ -86,7 +86,7 @@ pub enum CompressionFormat {
Lzma,
/// .sz
Snappy,
/// tar, tgz, tbz, tbz2, txz, tlz4, tlzma, tsz, tzst
/// tar, tgz, tbz, tbz2, txz, tlz4, tlzma, tsz, tzst, tzstd
Tar,
/// .zst
Zstd,
@ -124,14 +124,14 @@ fn to_extension(ext: &[u8]) -> Option<Extension> {
b"tlz4" => &[Tar, Lz4],
b"txz" | b"tlzma" => &[Tar, Lzma],
b"tsz" => &[Tar, Snappy],
b"tzst" => &[Tar, Zstd],
b"tzst" | b"tzstd" => &[Tar, Zstd],
b"zip" => &[Zip],
b"bz" | b"bz2" => &[Bzip],
b"gz" => &[Gzip],
b"lz4" => &[Lz4],
b"xz" | b"lzma" => &[Lzma],
b"sz" => &[Snappy],
b"zst" => &[Zstd],
b"zst" | b"zstd" => &[Zstd],
b"rar" => &[Rar],
b"7z" => &[SevenZip],
_ => return None,

View File

@ -17,7 +17,7 @@ fn sanity_check_through_mime() {
write_random_content(test_file, &mut SmallRng::from_entropy());
let formats = [
"7z", "tar", "zip", "tar.gz", "tgz", "tbz", "tbz2", "txz", "tlzma", "tzst", "tar.bz", "tar.bz2", "tar.lzma",
"7z", "tar", "zip", "tar.gz", "tgz", "tbz", "tbz2", "txz", "tlzma", "tzst", "tzstd", "tar.bz", "tar.bz2", "tar.lzma",
"tar.xz", "tar.zst",
];
@ -32,6 +32,7 @@ fn sanity_check_through_mime() {
"application/x-xz",
"application/x-xz",
"application/zstd",
"application/zstd",
"application/x-bzip2",
"application/x-bzip2",
"application/x-xz",

View File

@ -7,7 +7,7 @@ expression: "run_ouch(\"ouch decompress a\", dir)"
- Decompression formats are detected automatically from file extension
hint: Supported extensions are: tar, zip, bz, bz2, gz, lz4, xz, lzma, sz, zst, rar, 7z
hint: Supported aliases are: tgz, tbz, tlz4, txz, tzlma, tsz, tzst
hint: Supported aliases are: tgz, tbz, tlz4, txz, tzlma, tsz, tzst, zstd, tzstd
hint:
hint: Alternatively, you can pass an extension to the '--format' flag:
hint: ouch decompress <TMP_DIR>/a --format tar.gz

View File

@ -8,5 +8,5 @@ expression: "run_ouch(\"ouch decompress a b.unknown\", dir)"
- Decompression formats are detected automatically from file extension
hint: Supported extensions are: tar, zip, bz, bz2, gz, lz4, xz, lzma, sz, zst, rar, 7z
hint: Supported aliases are: tgz, tbz, tlz4, txz, tzlma, tsz, tzst
hint: Supported aliases are: tgz, tbz, tlz4, txz, tzlma, tsz, tzst, zstd, tzstd

View File

@ -7,7 +7,7 @@ expression: "run_ouch(\"ouch decompress b.unknown\", dir)"
- Decompression formats are detected automatically from file extension
hint: Supported extensions are: tar, zip, bz, bz2, gz, lz4, xz, lzma, sz, zst, rar, 7z
hint: Supported aliases are: tgz, tbz, tlz4, txz, tzlma, tsz, tzst
hint: Supported aliases are: tgz, tbz, tlz4, txz, tzlma, tsz, tzst, zstd, tzstd
hint:
hint: Alternatively, you can pass an extension to the '--format' flag:
hint: ouch decompress <TMP_DIR>/b.unknown --format tar.gz

View File

@ -7,7 +7,7 @@ expression: "run_ouch(\"ouch decompress a\", dir)"
- Decompression formats are detected automatically from file extension
hint: Supported extensions are: tar, zip, bz, bz2, gz, lz4, xz, lzma, sz, zst, 7z
hint: Supported aliases are: tgz, tbz, tlz4, txz, tzlma, tsz, tzst
hint: Supported aliases are: tgz, tbz, tlz4, txz, tzlma, tsz, tzst, zstd, tzstd
hint:
hint: Alternatively, you can pass an extension to the '--format' flag:
hint: ouch decompress <TMP_DIR>/a --format tar.gz

View File

@ -8,5 +8,5 @@ expression: "run_ouch(\"ouch decompress a b.unknown\", dir)"
- Decompression formats are detected automatically from file extension
hint: Supported extensions are: tar, zip, bz, bz2, gz, lz4, xz, lzma, sz, zst, 7z
hint: Supported aliases are: tgz, tbz, tlz4, txz, tzlma, tsz, tzst
hint: Supported aliases are: tgz, tbz, tlz4, txz, tzlma, tsz, tzst, zstd, tzstd

View File

@ -7,7 +7,7 @@ expression: "run_ouch(\"ouch decompress b.unknown\", dir)"
- Decompression formats are detected automatically from file extension
hint: Supported extensions are: tar, zip, bz, bz2, gz, lz4, xz, lzma, sz, zst, 7z
hint: Supported aliases are: tgz, tbz, tlz4, txz, tzlma, tsz, tzst
hint: Supported aliases are: tgz, tbz, tlz4, txz, tzlma, tsz, tzst, zstd, tzstd
hint:
hint: Alternatively, you can pass an extension to the '--format' flag:
hint: ouch decompress <TMP_DIR>/b.unknown --format tar.gz