pub struct SpecDefaultIf {
pub selector: String,
pub when: Option<String>,
pub value: String,
}Expand description
A default that applies when another flag is given.
Lives on the target flag, the inverse of SpecRequiresIf:
flag "--bin-names" { default_if "--json" "true" } binds true on
--bin-names when --json was given. Two arguments are clap’s
ArgPredicate::IsPresent; three (default_if "--output" "json" "pretty")
are Equals. First match wins. Command-line and environment values on
this flag suppress it; a default_if value is a default, not an explicit
value, so it does not activate requires_if.
clap 4 has Arg::default_value_if as a setter with no getter, so a spec
generated from a clap command never carries this — same hole as
SpecFlag::requires.
Fields§
§selector: StringThe other flag that decides whether this default applies ("--json").
when: Option<String>When set, the selector must have this explicit value (Equals).
When None, the selector only has to be present (IsPresent).
value: StringThe value to bind on this flag when the condition matches.
Trait Implementations§
Source§impl Clone for SpecDefaultIf
impl Clone for SpecDefaultIf
Source§fn clone(&self) -> SpecDefaultIf
fn clone(&self) -> SpecDefaultIf
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SpecDefaultIf
impl Debug for SpecDefaultIf
impl Eq for SpecDefaultIf
Source§impl PartialEq for SpecDefaultIf
impl PartialEq for SpecDefaultIf
Source§impl Serialize for SpecDefaultIf
impl Serialize for SpecDefaultIf
impl StructuralPartialEq for SpecDefaultIf
Auto Trait Implementations§
impl Freeze for SpecDefaultIf
impl RefUnwindSafe for SpecDefaultIf
impl Send for SpecDefaultIf
impl Sync for SpecDefaultIf
impl Unpin for SpecDefaultIf
impl UnsafeUnpin for SpecDefaultIf
impl UnwindSafe for SpecDefaultIf
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,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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