mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-05-19 01:30:21 -07:00
parent
1ae121122f
commit
0b04553aff
@ -352,6 +352,8 @@ fn default_decompression_commands() -> Vec<DecompressionCommand> {
|
|||||||
const ARGS_XZ: &[&str] = &["xz", "-d", "-c"];
|
const ARGS_XZ: &[&str] = &["xz", "-d", "-c"];
|
||||||
const ARGS_LZ4: &[&str] = &["lz4", "-d", "-c"];
|
const ARGS_LZ4: &[&str] = &["lz4", "-d", "-c"];
|
||||||
const ARGS_LZMA: &[&str] = &["xz", "--format=lzma", "-d", "-c"];
|
const ARGS_LZMA: &[&str] = &["xz", "--format=lzma", "-d", "-c"];
|
||||||
|
const ARGS_BROTLI: &[&str] = &["brotli", "-d", "-c"];
|
||||||
|
const ARGS_ZSTD: &[&str] = &["zstd", "-q", "-d", "-c"];
|
||||||
|
|
||||||
fn cmd(glob: &str, args: &[&str]) -> DecompressionCommand {
|
fn cmd(glob: &str, args: &[&str]) -> DecompressionCommand {
|
||||||
DecompressionCommand {
|
DecompressionCommand {
|
||||||
@ -367,15 +369,14 @@ fn default_decompression_commands() -> Vec<DecompressionCommand> {
|
|||||||
vec![
|
vec![
|
||||||
cmd("*.gz", ARGS_GZIP),
|
cmd("*.gz", ARGS_GZIP),
|
||||||
cmd("*.tgz", ARGS_GZIP),
|
cmd("*.tgz", ARGS_GZIP),
|
||||||
|
|
||||||
cmd("*.bz2", ARGS_BZIP),
|
cmd("*.bz2", ARGS_BZIP),
|
||||||
cmd("*.tbz2", ARGS_BZIP),
|
cmd("*.tbz2", ARGS_BZIP),
|
||||||
|
|
||||||
cmd("*.xz", ARGS_XZ),
|
cmd("*.xz", ARGS_XZ),
|
||||||
cmd("*.txz", ARGS_XZ),
|
cmd("*.txz", ARGS_XZ),
|
||||||
|
|
||||||
cmd("*.lz4", ARGS_LZ4),
|
cmd("*.lz4", ARGS_LZ4),
|
||||||
|
|
||||||
cmd("*.lzma", ARGS_LZMA),
|
cmd("*.lzma", ARGS_LZMA),
|
||||||
|
cmd("*.br", ARGS_BROTLI),
|
||||||
|
cmd("*.zst", ARGS_ZSTD),
|
||||||
|
cmd("*.zstd", ARGS_ZSTD),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -2021,9 +2021,9 @@ This flag can be used with the -o/--only-matching flag.
|
|||||||
fn flag_search_zip(args: &mut Vec<RGArg>) {
|
fn flag_search_zip(args: &mut Vec<RGArg>) {
|
||||||
const SHORT: &str = "Search in compressed files.";
|
const SHORT: &str = "Search in compressed files.";
|
||||||
const LONG: &str = long!("\
|
const LONG: &str = long!("\
|
||||||
Search in compressed files. Currently gz, bz2, xz, lzma and lz4 files are
|
Search in compressed files. Currently gzip, bzip2, xz, LZ4, LZMA, Brotli and
|
||||||
supported. This option expects the decompression binaries to be available in
|
Zstd files are supported. This option expects the decompression binaries to be
|
||||||
your PATH.
|
available in your PATH.
|
||||||
|
|
||||||
This flag can be disabled with --no-search-zip.
|
This flag can be disabled with --no-search-zip.
|
||||||
");
|
");
|
||||||
|
2
tests/data/sherlock.br
Normal file
2
tests/data/sherlock.br
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
n═ет-_ё.· бЮХНcM√∙╢┘YН4■ЧЪжЖYa╓-L╡O(б8юsn^Gwя┬!,╣
|
||||||
|
KD▄■/7┤Кth┐л╢р]jйЕтаЁE_;dЮrF╘Qsх/:DIVB}╒T7└┌я╣щЦH│2▄Гя)СдM[uаУПi┴©пЦ50з╝░Y6╟В┐р⌠╝Х╛░%░в╗_═╘U by⌠4╔├о═┌!&пgИ█#М
|
BIN
tests/data/sherlock.zst
Normal file
BIN
tests/data/sherlock.zst
Normal file
Binary file not shown.
@ -909,6 +909,36 @@ be, to a very large extent, the result of luck. Sherlock Holmes
|
|||||||
eqnice!(expected, cmd.stdout());
|
eqnice!(expected, cmd.stdout());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
rgtest!(compressed_brotli, |dir: Dir, mut cmd: TestCommand| {
|
||||||
|
if !cmd_exists("brotli") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dir.create_bytes("sherlock.br", include_bytes!("./data/sherlock.br"));
|
||||||
|
cmd.arg("-z").arg("Sherlock").arg("sherlock.br");
|
||||||
|
|
||||||
|
let expected = "\
|
||||||
|
For the Doctor Watsons of this world, as opposed to the Sherlock
|
||||||
|
be, to a very large extent, the result of luck. Sherlock Holmes
|
||||||
|
";
|
||||||
|
eqnice!(expected, cmd.stdout());
|
||||||
|
});
|
||||||
|
|
||||||
|
rgtest!(compressed_zstd, |dir: Dir, mut cmd: TestCommand| {
|
||||||
|
if !cmd_exists("zstd") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dir.create_bytes("sherlock.zst", include_bytes!("./data/sherlock.zst"));
|
||||||
|
cmd.arg("-z").arg("Sherlock").arg("sherlock.zst");
|
||||||
|
|
||||||
|
let expected = "\
|
||||||
|
For the Doctor Watsons of this world, as opposed to the Sherlock
|
||||||
|
be, to a very large extent, the result of luck. Sherlock Holmes
|
||||||
|
";
|
||||||
|
eqnice!(expected, cmd.stdout());
|
||||||
|
});
|
||||||
|
|
||||||
rgtest!(compressed_failing_gzip, |dir: Dir, mut cmd: TestCommand| {
|
rgtest!(compressed_failing_gzip, |dir: Dir, mut cmd: TestCommand| {
|
||||||
if !cmd_exists("gzip") {
|
if !cmd_exists("gzip") {
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user