Enum rg::app::RGArgKind

source ·
pub enum RGArgKind {
    Positional {
        value_name: &'static str,
        multiple: bool,
    },
    Switch {
        long: &'static str,
        short: Option<&'static str>,
        multiple: bool,
    },
    Flag {
        long: &'static str,
        short: Option<&'static str>,
        value_name: &'static str,
        multiple: bool,
        possible_values: Vec<&'static str>,
    },
}
Expand description

The kind of a ripgrep argument.

This can be one of three possibilities: a positional argument, a boolean switch flag or a flag that accepts exactly one argument. Each variant stores argument type specific data.

Note that clap supports more types of arguments than this, but we don’t (and probably shouldn’t) use them in ripgrep.

Finally, note that we don’t capture all state about an argument in this type. Some state is only known to clap. There isn’t any particular reason why; the state we do capture is motivated by use cases (like generating documentation).

Variants§

§

Positional

Fields

§value_name: &'static str

The name of the value used in the -h/--help output. By convention, this is an all-uppercase string. e.g., PATH or PATTERN.

§multiple: bool

Whether an argument can be repeated multiple times or not.

The only argument this applies to is PATH, where an end user can specify multiple paths for ripgrep to search.

If this is disabled, then an argument can only be provided once. For example, PATTERN is one such argument. (Note that the -e/–regexp flag is distinct from the positional PATTERN argument, and it can be provided multiple times.)

A positional argument.

§

Switch

Fields

§long: &'static str

The long name of a flag. This is always non-empty.

§short: Option<&'static str>

The short name of a flag. This is empty if a flag only has a long name.

§multiple: bool

Whether this switch can be provided multiple times where meaning is attached to the number of times this flag is given.

Note that every switch can be provided multiple times. This particular state indicates whether all instances of a switch are relevant or not.

For example, the -u/–unrestricted flag can be provided multiple times where each repeated use of it indicates more relaxing of ripgrep’s filtering. Conversely, the -i/–ignore-case flag can also be provided multiple times, but it is simply considered either present or not. In these cases, -u/–unrestricted has multiple set to true while -i/–ignore-case has multiple set to false.

A boolean switch.

§

Flag

Fields

§long: &'static str

The long name of a flag. This is always non-empty.

§short: Option<&'static str>

The short name of a flag. This is empty if a flag only has a long name.

§value_name: &'static str

The name of the value used in the -h/--help output. By convention, this is an all-uppercase string. e.g., PATH or PATTERN.

§multiple: bool

Whether this flag can be provided multiple times with multiple distinct values.

Note that every flag can be provided multiple times. This particular state indicates whether all instances of a flag are relevant or not.

For example, the -g/–glob flag can be provided multiple times and all of its values should be interpreted by ripgrep. Conversely, while the -C/–context flag can also be provided multiple times, only its last instance is used while all previous instances are ignored. In these cases, -g/–glob has multiple set to true while -C/–context has multiple set to false.

§possible_values: Vec<&'static str>

A set of possible values for this flag. If an end user provides any value other than what’s in this set, then clap will report an error.

A flag the accepts a single value.

Trait Implementations§

source§

impl Clone for RGArgKind

source§

fn clone(&self) -> RGArgKind

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

Auto Trait Implementations§

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.