#[non_exhaustive]pub struct SpecChoices {
pub choices: Vec<String>,
pub details: Vec<SpecChoice>,
pub ignore_case: bool,
pub strict: bool,
pub run: Option<String>,
}Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.choices: Vec<String>§details: Vec<SpecChoice>Metadata for canonical values that need more than the shorthand string form.
ignore_case: boolMatch canonical values and aliases without regard to ASCII case.
strict: boolWhether values outside the declared set are rejected.
run: Option<String>A shell command whose output lists further values, one per line.
Run only where a program is running: when a value is checked, when a word is being
completed, and for a help page asked for with crate::docs::cli::render_runtime_help
or by --help during a parse. Generated documentation and code never run it, and
describe it instead.
Implementations§
Source§impl SpecChoices
impl SpecChoices
Sourcepub fn new(choices: impl IntoIterator<Item = impl Into<String>>) -> Self
pub fn new(choices: impl IntoIterator<Item = impl Into<String>>) -> Self
The set of values an arg or flag accepts.
Source§impl SpecChoices
impl SpecChoices
pub fn env(&self) -> Option<&str>
Sourcepub fn run(&self) -> Option<&str>
pub fn run(&self) -> Option<&str>
The command whose output lists further values, if the choices name one.
Sourcepub fn values(&self) -> Vec<String>
pub fn values(&self) -> Vec<String>
The declared values, and those named by env=. Never runs run=: see
Self::values_from_run and Self::resolved_values for that.
Sourcepub fn values_from_run(
&self,
env: Option<&HashMap<String, String>>,
) -> Result<Vec<String>, UsageErr>
pub fn values_from_run( &self, env: Option<&HashMap<String, String>>, ) -> Result<Vec<String>, UsageErr>
Run run= and return the values it printed: one per line, trimmed, with blank lines
skipped. Empty when the choices name no command.
env is added to the command’s environment, for a caller parsing against a
different one (see crate::Parser::with_env). Within a single parse or help page the
same command runs once, however many values are checked against it.
Trait Implementations§
Source§impl Clone for SpecChoices
impl Clone for SpecChoices
Source§impl Debug for SpecChoices
impl Debug for SpecChoices
Source§impl Default for SpecChoices
impl Default for SpecChoices
Source§impl<'de> Deserialize<'de> for SpecChoices
impl<'de> Deserialize<'de> for SpecChoices
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for SpecChoices
impl RefUnwindSafe for SpecChoices
impl Send for SpecChoices
impl Sync for SpecChoices
impl Unpin for SpecChoices
impl UnsafeUnpin for SpecChoices
impl UnwindSafe for SpecChoices
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more