Struct tauri_utils::config::CliArg

source ·
pub struct CliArg {
Show 23 fields pub short: Option<char>, pub name: String, pub description: Option<String>, pub long_description: Option<String>, pub takes_value: bool, pub multiple: bool, pub multiple_occurrences: bool, pub number_of_values: Option<usize>, pub possible_values: Option<Vec<String>>, pub min_values: Option<usize>, pub max_values: Option<usize>, pub required: bool, pub required_unless_present: Option<String>, pub required_unless_present_all: Option<Vec<String>>, pub required_unless_present_any: Option<Vec<String>>, pub conflicts_with: Option<String>, pub conflicts_with_all: Option<Vec<String>>, pub requires: Option<String>, pub requires_all: Option<Vec<String>>, pub requires_if: Option<Vec<String>>, pub required_if_eq: Option<Vec<String>>, pub require_equals: Option<bool>, pub index: Option<usize>,
}
Expand description

A CLI argument definition.

Fields§

§short: Option<char>

The short version of the argument, without the preceding -.

NOTE: Any leading - characters will be stripped, and only the first non-character will be used as the short version.

§name: String

The unique argument name

§description: Option<String>

The argument description which will be shown on the help information. Typically, this is a short (one line) description of the arg.

§long_description: Option<String>

The argument long description which will be shown on the help information. Typically this a more detailed (multi-line) message that describes the argument.

§takes_value: bool

Specifies that the argument takes a value at run time.

NOTE: values for arguments may be specified in any of the following methods

  • Using a space such as -o value or –option value
  • Using an equals and no space such as -o=value or –option=value
  • Use a short and no space such as -ovalue
§multiple: bool

Specifies that the argument may have an unknown number of multiple values. Without any other settings, this argument may appear only once.

For example, –opt val1 val2 is allowed, but –opt val1 val2 –opt val3 is not.

NOTE: Setting this requires takes_value to be set to true.

§multiple_occurrences: bool

Specifies that the argument may appear more than once. For flags, this results in the number of occurrences of the flag being recorded. For example -ddd or -d -d -d would count as three occurrences. For options or arguments that take a value, this does not affect how many values they can accept. (i.e. only one at a time is allowed)

For example, –opt val1 –opt val2 is allowed, but –opt val1 val2 is not.

§number_of_values: Option<usize>

Specifies how many values are required to satisfy this argument. For example, if you had a -f <file> argument where you wanted exactly 3 ‘files’ you would set number_of_values = 3, and this argument wouldn’t be satisfied unless the user provided 3 and only 3 values.

NOTE: Does not require multiple_occurrences = true to be set. Setting multiple_occurrences = true would allow -f <file> <file> <file> -f <file> <file> <file> where as not setting it would only allow one occurrence of this argument.

NOTE: implicitly sets takes_value = true and multiple_values = true.

§possible_values: Option<Vec<String>>

Specifies a list of possible values for this argument. At runtime, the CLI verifies that only one of the specified values was used, or fails with an error message.

§min_values: Option<usize>

Specifies the minimum number of values for this argument. For example, if you had a -f <file> argument where you wanted at least 2 ‘files’, you would set minValues: 2, and this argument would be satisfied if the user provided, 2 or more values.

§max_values: Option<usize>

Specifies the maximum number of values are for this argument. For example, if you had a -f <file> argument where you wanted up to 3 ‘files’, you would set .max_values(3), and this argument would be satisfied if the user provided, 1, 2, or 3 values.

§required: bool

Sets whether or not the argument is required by default.

  • Required by default means it is required, when no other conflicting rules have been evaluated
  • Conflicting rules take precedence over being required.
§required_unless_present: Option<String>

Sets an arg that override this arg’s required setting i.e. this arg will be required unless this other argument is present.

§required_unless_present_all: Option<Vec<String>>

Sets args that override this arg’s required setting i.e. this arg will be required unless all these other arguments are present.

§required_unless_present_any: Option<Vec<String>>

Sets args that override this arg’s required setting i.e. this arg will be required unless at least one of these other arguments are present.

§conflicts_with: Option<String>

Sets a conflicting argument by name i.e. when using this argument, the following argument can’t be present and vice versa.

§conflicts_with_all: Option<Vec<String>>

The same as conflictsWith but allows specifying multiple two-way conflicts per argument.

§requires: Option<String>

Tets an argument by name that is required when this one is present i.e. when using this argument, the following argument must be present.

§requires_all: Option<Vec<String>>

Sts multiple arguments by names that are required when this one is present i.e. when using this argument, the following arguments must be present.

§requires_if: Option<Vec<String>>

Allows a conditional requirement with the signature [arg, value] the requirement will only become valid if arg’s value equals ${value}.

§required_if_eq: Option<Vec<String>>

Allows specifying that an argument is required conditionally with the signature [arg, value] the requirement will only become valid if the arg’s value equals ${value}.

§require_equals: Option<bool>

Requires that options use the –option=val syntax i.e. an equals between the option and associated value.

§index: Option<usize>

The positional argument index, starting at 1.

The index refers to position according to other positional argument. It does not define position in the argument list as a whole. When utilized with multiple=true, only the last positional argument may be defined as multiple (i.e. the one with the highest index).

Trait Implementations§

source§

impl Clone for CliArg

source§

fn clone(&self) -> CliArg

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 CliArg

source§

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

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for CliArg

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl PartialEq for CliArg

source§

fn eq(&self, other: &CliArg) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for CliArg

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for CliArg

source§

impl StructuralPartialEq for CliArg

Auto Trait Implementations§

§

impl Freeze for CliArg

§

impl RefUnwindSafe for CliArg

§

impl Send for CliArg

§

impl Sync for CliArg

§

impl Unpin for CliArg

§

impl UnwindSafe for CliArg

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where 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> ToOwned for T
where 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 T
where 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 T
where 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.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,