Skip to main content

TupleType

Struct TupleType 

Source
pub struct TupleType { /* private fields */ }
Expand description

A composite parameter type that collects multiple values with different types.

Unlike regular types with nargs, each position in a tuple can have a different type.

Implementations§

Source§

impl TupleType

Source

pub fn new<I, S>(types: I) -> Self
where I: IntoIterator<Item = S>, S: AsRef<str>,

Create a new tuple type from a list of type specifiers.

Each specifier should be one of: “string”, “int”, “float”, “bool”

Source

pub fn strings(count: usize) -> Self

Create a tuple of strings.

Source

pub fn ints(count: usize) -> Self

Create a tuple of integers.

Source§

impl TupleType

Source

pub fn convert_element( &self, index: usize, value: &str, ) -> Result<TupleValue, String>

Convert a single element at the given index.

This is the preferred way to convert tuple elements - the parser should call this once for each argument consumed.

Source

pub fn convert_values(&self, values: &[&str]) -> Result<Vec<TupleValue>, String>

Convert a slice of pre-split values into a tuple.

This is the standard Click-compatible conversion - the parser provides already-split argument values.

Trait Implementations§

Source§

impl Debug for TupleType

Source§

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

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

impl TypeConverter for TupleType

Source§

type Value = Vec<TupleValue>

The Rust type that this parameter type converts to.
Source§

fn name(&self) -> &str

Returns the descriptive name of this type (used in error messages).
Source§

fn convert(&self, value: &str) -> Result<Self::Value, String>

Convert a string value to the target type. Read more
Source§

fn get_metavar(&self) -> Option<String>

Returns the metavar for this type (used in help text). Read more
Source§

fn is_composite(&self) -> bool

Whether this type is a composite type (like Tuple).
Source§

fn arity(&self) -> usize

The arity (number of values consumed) for composite types.
Source§

fn get_missing_message(&self) -> Option<String>

Returns an optional message when a required value is missing.
Source§

fn split_envvar_value(&self, value: &str) -> Vec<String>

Split an environment variable value into multiple values. Read more
Source§

fn shell_complete(&self, _incomplete: &str) -> Vec<CompletionItem>

Returns shell completion items for the given incomplete value. Read more

Auto Trait Implementations§

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> AnyTypeConverter for T
where T: TypeConverter + Send + Sync, <T as TypeConverter>::Value: Send + Sync + 'static,

Source§

fn name(&self) -> &str

Returns the descriptive name of this type.
Source§

fn convert_any(&self, value: &str) -> Result<Box<dyn Any + Sync + Send>, String>

Convert a string value to the target type, returning as Box.
Source§

fn convert_multi( &self, values: &[String], ) -> Result<Box<dyn Any + Sync + Send>, String>

Convert multiple string values to the target type, returning as Box. Read more
Source§

fn get_metavar(&self) -> Option<String>

Returns the metavar for this type.
Source§

fn split_envvar_value(&self, value: &str) -> Vec<String>

Split an environment variable value into multiple values.
Source§

fn shell_complete(&self, incomplete: &str) -> Vec<CompletionItem>

Returns shell completion items for the given incomplete value.
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<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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.