pub struct Args(Arc<ArgsImp>);
Expand description
The primary configuration object used throughout ripgrep. It provides a high-level convenient interface to the provided command line arguments.
An Args
object is cheap to clone and can be used from multiple threads
simultaneously.
Tuple Fields§
§0: Arc<ArgsImp>
Implementations§
source§impl Args
impl Args
sourcepub fn parse() -> Result<Args, Box<dyn Error>>
pub fn parse() -> Result<Args, Box<dyn Error>>
Parse the command line arguments for this process.
If a CLI usage error occurred, then exit the process and print a usage or error message. Similarly, if the user requested the version of ripgrep, then print the version and exit.
Also, initialize a global logger.
sourcefn matches(&self) -> &ArgMatches
fn matches(&self) -> &ArgMatches
Return direct access to command line arguments.
sourcefn matcher(&self) -> &PatternMatcher
fn matcher(&self) -> &PatternMatcher
Return the matcher builder from the patterns.
sourcefn paths(&self) -> &[PathBuf]
fn paths(&self) -> &[PathBuf]
Return the paths found in the command line arguments. This is guaranteed to be non-empty. In the case where no explicit arguments are provided, a single default path is provided automatically.
sourcepub fn using_default_path(&self) -> bool
pub fn using_default_path(&self) -> bool
Returns true if and only if paths
had to be populated with a default
path, which occurs only when no paths were given as command line
arguments.
source§impl Args
impl Args
High level public routines for building data structures used by ripgrep from command line arguments.
sourcepub fn buffer_writer(&self) -> Result<BufferWriter, Box<dyn Error>>
pub fn buffer_writer(&self) -> Result<BufferWriter, Box<dyn Error>>
Create a new buffer writer for multi-threaded printing with color support.
sourcepub fn path_printer<W: WriteColor>(
&self,
wtr: W
) -> Result<PathPrinter<W>, Box<dyn Error>>
pub fn path_printer<W: WriteColor>( &self, wtr: W ) -> Result<PathPrinter<W>, Box<dyn Error>>
Builder a path printer that can be used for printing just file paths, with optional color support.
The printer will print paths to the given writer.
sourcepub fn quit_after_match(&self) -> Result<bool, Box<dyn Error>>
pub fn quit_after_match(&self) -> Result<bool, Box<dyn Error>>
Returns true if and only if the search should quit after finding the first match.
sourcepub fn search_worker<W: WriteColor>(
&self,
wtr: W
) -> Result<SearchWorker<W>, Box<dyn Error>>
pub fn search_worker<W: WriteColor>( &self, wtr: W ) -> Result<SearchWorker<W>, Box<dyn Error>>
Build a worker for executing searches.
Search results are written to the given writer.
sourcepub fn stats(&self) -> Result<Option<Stats>, Box<dyn Error>>
pub fn stats(&self) -> Result<Option<Stats>, Box<dyn Error>>
Returns a zero value for tracking statistics if and only if it has been requested.
When this returns a Stats
value, then it is guaranteed that the
search worker will be configured to track statistics as well.
sourcepub fn subject_builder(&self) -> SubjectBuilder
pub fn subject_builder(&self) -> SubjectBuilder
Return a builder for constructing subjects. A subject represents a single unit of something to search. Typically, this corresponds to a file or a stream such as stdin.
sourcepub fn stdout(&self) -> StandardStream
pub fn stdout(&self) -> StandardStream
Execute the given function with a writer to stdout that enables color support based on the command line configuration.
sourcepub fn type_defs(&self) -> Result<Vec<FileTypeDef>, Box<dyn Error>>
pub fn type_defs(&self) -> Result<Vec<FileTypeDef>, Box<dyn Error>>
Return the type definitions compiled into ripgrep.
If there was a problem reading and parsing the type definitions, then this returns an error.
sourcepub fn walker(&self) -> Result<Walk, Box<dyn Error>>
pub fn walker(&self) -> Result<Walk, Box<dyn Error>>
Return a walker that never uses additional threads.
sourcepub fn needs_stat_sort(&self) -> bool
pub fn needs_stat_sort(&self) -> bool
Returns true if and only if stat
-related sorting is required
sourcepub fn sort_by_stat<I>(&self, subjects: I) -> Vec<Subject>where
I: Iterator<Item = Subject>,
pub fn sort_by_stat<I>(&self, subjects: I) -> Vec<Subject>where I: Iterator<Item = Subject>,
Sort subjects if a sorter is specified, but only if the sort requires stat calls. Non-stat related sorts are handled during file traversal
This function assumes that it is known that a stat-related sort is required, and does not check for it again.
It is important that that precondition is fulfilled, since this function consumes the subjects iterator, and is therefore a blocking function.
sourcepub fn walker_parallel(&self) -> Result<WalkParallel, Box<dyn Error>>
pub fn walker_parallel(&self) -> Result<WalkParallel, Box<dyn Error>>
Return a parallel walker that may use additional threads.