Struct rg::args::Args

source ·
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

source

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.

source

fn matches(&self) -> &ArgMatches

Return direct access to command line arguments.

source

fn matcher(&self) -> &PatternMatcher

Return the matcher builder from the patterns.

source

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.

source

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

fn printer<W: WriteColor>(&self, wtr: W) -> Result<Printer<W>, Box<dyn Error>>

Return the printer that should be used for formatting the output of search results.

The returned printer will write results to the given writer.

source§

impl Args

High level public routines for building data structures used by ripgrep from command line arguments.

source

pub fn buffer_writer(&self) -> Result<BufferWriter, Box<dyn Error>>

Create a new buffer writer for multi-threaded printing with color support.

source

pub fn command(&self) -> Command

Return the high-level command that ripgrep should run.

source

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.

source

pub fn quiet(&self) -> bool

Returns true if and only if ripgrep should be “quiet.”

source

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.

source

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.

source

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.

source

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.

source

pub fn stdout(&self) -> StandardStream

Execute the given function with a writer to stdout that enables color support based on the command line configuration.

source

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.

source

pub fn walker(&self) -> Result<Walk, Box<dyn Error>>

Return a walker that never uses additional threads.

source

pub fn needs_stat_sort(&self) -> bool

Returns true if and only if stat-related sorting is required

source

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.

source

pub fn walker_parallel(&self) -> Result<WalkParallel, Box<dyn Error>>

Return a parallel walker that may use additional threads.

Trait Implementations§

source§

impl Clone for Args

source§

fn clone(&self) -> Args

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Args

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Args

§

impl Send for Args

§

impl Sync for Args

§

impl Unpin for Args

§

impl UnwindSafe for Args

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.