diff --git a/README.md b/README.md index e90af38..9784ddb 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,6 @@ rga is a tool to recursively search for text in many different types of files. I [![Linux build status](https://travis-ci.org/phiresky/ripgrep_all.svg)](https://travis-ci.org/BurntSushi/ripgrep) [![Crates.io](https://img.shields.io/crates/v/ripgrep_all.svg)](https://crates.io/crates/ripgrep_all) -similar: - # todo - jpg adapter (based on object classification / detection (yolo?)) for fun diff --git a/src/adapters.rs b/src/adapters.rs index c75f969..cdcc6ce 100644 --- a/src/adapters.rs +++ b/src/adapters.rs @@ -11,7 +11,7 @@ use crate::matching::*; use crate::preproc::PreprocConfig; use failure::*; use log::*; -use regex::{Regex, RegexSet}; +use regex::{Regex}; use std::borrow::Cow; use std::collections::HashMap; use std::io::prelude::*; diff --git a/src/adapters/pdfpages.rs b/src/adapters/pdfpages.rs index 0705935..52912a9 100644 --- a/src/adapters/pdfpages.rs +++ b/src/adapters/pdfpages.rs @@ -1,16 +1,16 @@ use super::*; use crate::adapters::spawning::map_exe_error; -use crate::adapters::spawning::pipe_output; + use crate::preproc::rga_preproc; use lazy_static::lazy_static; -use spawning::SpawningFileAdapter; + use std::fs::File; use std::io::BufReader; -use std::io::Cursor; -use std::io::Take; + + use std::path::PathBuf; use std::process::Command; -use std::process::Stdio; + static EXTENSIONS: &[&str] = &["pdf"]; @@ -46,7 +46,7 @@ impl FileAdapter for PdfPagesAdapter { let AdaptInfo { filepath_hint, is_real_file, - mut inp, + inp: _, oup, line_prefix, archive_recursion_depth, diff --git a/src/args.rs b/src/args.rs index 868f45d..c63f847 100644 --- a/src/args.rs +++ b/src/args.rs @@ -32,35 +32,46 @@ set_default!(max_archive_recursion, 4, i32); #[structopt(rename_all = "kebab-case", set_term_width = 80)] pub struct RgaArgs { #[serde(default, skip_serializing_if = "is_default")] - #[structopt(long = "--rga-no-cache", help = "Disable caching of results")] + #[structopt(long = "--rga-no-cache")] + /// Disable caching of results + /// + /// By default, rga caches the extracted text to a database in ~/.cache/rga if it is small enough. + /// This way, repeated searches on the same set of files will be much faster. + /// If you pass this flag, all caching will be disabled. pub no_cache: bool, #[serde(default, skip_serializing_if = "is_default")] - #[structopt( - long = "--rga-accurate", - help = "Use more accurate but slower matching by mime type" - )] + #[structopt(long = "--rga-accurate")] + /// Use more accurate but slower matching by mime type + /// + /// By default, rga will match files using file extensions. + /// Some programs, such as sqlite3, don't care about the file extension at all, + /// so users sometimes use any or no extension at all. With this flag, rga + /// will try to detect the mime type of input files using the magic bytes + /// (similar to the `file` utility), and use that to choose the adapter. pub accurate: bool, #[serde(default, skip_serializing_if = "is_default")] #[structopt( long = "--rga-adapters", require_equals = true, - require_delimiter = true, - help = "Change which adapters to use and in which priority order (descending)" + require_delimiter = true )] + /// Change which adapters to use and in which priority order (descending) + /// + /// "foo,bar" means use only adapters foo and bar. + /// "-bar,baz" means use all default adapters except for bar and baz. + /// "+bar,baz" means use all default adapters and also bar and baz. pub adapters: Vec, #[serde( default = "def_cache_max_blob_len", skip_serializing_if = "def_cache_max_blob_len_if" )] - #[structopt( - long = "--rga-cache-max-blob-len", - default_value = "2000000", - help = "Max compressed size to cache", - long_help = "Longest byte length (after compression) to store in cache. Longer adapter outputs will not be cached and recomputed every time." - )] + #[structopt(long = "--rga-cache-max-blob-len", default_value = "2000000")] + /// Max compressed size to cache + /// + /// Longest byte length (after compression) to store in cache. Longer adapter outputs will not be cached and recomputed every time. pub cache_max_blob_len: u32, #[serde( @@ -69,10 +80,12 @@ pub struct RgaArgs { )] #[structopt( long = "--rga-cache-compression-level", + hidden_short_help = true, default_value = "12", require_equals = true, - help = "ZSTD compression level to apply to adapter outputs before storing in cache db" + help = "" )] + /// ZSTD compression level to apply to adapter outputs before storing in cache db pub cache_compression_level: u32, #[serde( diff --git a/src/bin/rga-preproc.rs b/src/bin/rga-preproc.rs index d323e29..ae586f3 100644 --- a/src/bin/rga-preproc.rs +++ b/src/bin/rga-preproc.rs @@ -1,4 +1,4 @@ -use failure::{format_err, Fallible}; +use failure::{Fallible}; use rga::adapters::*; use rga::preproc::*; use ripgrep_all as rga; diff --git a/src/bin/rga.rs b/src/bin/rga.rs index 1324a70..64c7923 100644 --- a/src/bin/rga.rs +++ b/src/bin/rga.rs @@ -35,7 +35,7 @@ fn main() -> Fallible<()> { for adapter in enabled_adapters { print(adapter) } - println!("The following adapters are disabled by default, and can be enabled using '--rga-adapters=+tesseract,xyz':\n"); + println!("The following adapters are disabled by default, and can be enabled using '--rga-adapters=+pdfpages,tesseract':\n"); for adapter in disabled_adapters { print(adapter) }