pub struct SpecFlagBuilder { /* private fields */ }Expand description
Builder for SpecFlag
Implementations§
Source§impl SpecFlagBuilder
impl SpecFlagBuilder
Sourcepub fn shorts(self, chars: impl IntoIterator<Item = char>) -> Self
pub fn shorts(self, chars: impl IntoIterator<Item = char>) -> Self
Add multiple short flags at once
Sourcepub fn long(self, name: impl Into<String>) -> Self
pub fn long(self, name: impl Into<String>) -> Self
Add a long flag name (can be called multiple times)
Sourcepub fn default_value(self, value: impl Into<String>) -> Self
pub fn default_value(self, value: impl Into<String>) -> Self
Add a default value (can be called multiple times for var flags)
Sourcepub fn default_values<I, S>(self, values: I) -> Self
pub fn default_values<I, S>(self, values: I) -> Self
Add multiple default values at once
Sourcepub fn required_if(self, flag: impl Into<String>) -> Self
pub fn required_if(self, flag: impl Into<String>) -> Self
Add a flag whose presence makes this flag required
Sourcepub fn required_if_any<I, S>(self, flags: I) -> Self
pub fn required_if_any<I, S>(self, flags: I) -> Self
Add flags whose presence makes this flag required
Sourcepub fn required_if_eq(
self,
selector: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn required_if_eq( self, selector: impl Into<String>, value: impl Into<String>, ) -> Self
Add a selector/value condition that makes this flag required.
Sourcepub fn required_if_eq_all<I, S, V>(self, conditions: I) -> Self
pub fn required_if_eq_all<I, S, V>(self, conditions: I) -> Self
Set selector/value conditions which must all match to require this flag.
Sourcepub fn required_unless(self, flag: impl Into<String>) -> Self
pub fn required_unless(self, flag: impl Into<String>) -> Self
Add a flag whose absence makes this flag required
Sourcepub fn required_unless_any<I, S>(self, flags: I) -> Self
pub fn required_unless_any<I, S>(self, flags: I) -> Self
Add flags where the absence of all of them makes this flag required
Sourcepub fn required_unless_all<I, S>(self, flags: I) -> Self
pub fn required_unless_all<I, S>(self, flags: I) -> Self
Add selectors which must all be present to waive this flag’s requirement.
Sourcepub fn allow_hyphen_values(self, allow: bool) -> Self
pub fn allow_hyphen_values(self, allow: bool) -> Self
Allow this flag’s value to start with -
Sourcepub fn require_equals(self, require: bool) -> Self
pub fn require_equals(self, require: bool) -> Self
Require --flag=value and refuse --flag value.
Sourcepub fn value_optional(self, optional: bool) -> Self
pub fn value_optional(self, optional: bool) -> Self
Allow this flag to be present without a value.
Sourcepub fn bool_value(self, enabled: bool) -> Self
pub fn bool_value(self, enabled: bool) -> Self
Allow --flag=true and --flag=false on a boolean switch.
Sourcepub fn default_missing(self, value: impl Into<String>) -> Self
pub fn default_missing(self, value: impl Into<String>) -> Self
Value used when the flag is present but no value is given.
Sourcepub fn override_with(self, flag: impl Into<String>) -> Self
pub fn override_with(self, flag: impl Into<String>) -> Self
Add a flag that this flag mutually overrides
Sourcepub fn overrides_with<I, S>(self, flags: I) -> Self
pub fn overrides_with<I, S>(self, flags: I) -> Self
Add flags that this flag mutually overrides
Sourcepub fn require(self, flag: impl Into<String>) -> Self
pub fn require(self, flag: impl Into<String>) -> Self
Add a flag that must also be given when this one is
Sourcepub fn requires<I, S>(self, flags: I) -> Self
pub fn requires<I, S>(self, flags: I) -> Self
Add flags that must also be given when this one is
Sourcepub fn requires_if(
self,
value: impl Into<String>,
flag: impl Into<String>,
) -> Self
pub fn requires_if( self, value: impl Into<String>, flag: impl Into<String>, ) -> Self
Add a flag required when this flag is explicitly given value
Sourcepub fn requires_ifs<I, V, S>(self, requirements: I) -> Self
pub fn requires_ifs<I, V, S>(self, requirements: I) -> Self
Add value-conditional flag requirements
Sourcepub fn default_if(
self,
selector: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn default_if( self, selector: impl Into<String>, value: impl Into<String>, ) -> Self
Bind value on this flag when selector is present.
clap’s default_value_if(id, ArgPredicate::IsPresent, value).
Sourcepub fn default_if_eq(
self,
selector: impl Into<String>,
when: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn default_if_eq( self, selector: impl Into<String>, when: impl Into<String>, value: impl Into<String>, ) -> Self
Bind value on this flag when selector is explicitly when.
clap’s default_value_if(id, ArgPredicate::Equals(when), value).
Sourcepub fn default_ifs<I>(self, conditions: I) -> Selfwhere
I: IntoIterator<Item = SpecDefaultIf>,
pub fn default_ifs<I>(self, conditions: I) -> Selfwhere
I: IntoIterator<Item = SpecDefaultIf>,
Add several conditional defaults, in first-match-wins order.
Sourcepub fn help_heading(self, help_heading: impl Into<String>) -> Self
pub fn help_heading(self, help_heading: impl Into<String>) -> Self
Heading to list this under in help output.
Sourcepub fn action(self, action: SpecFlagAction) -> Self
pub fn action(self, action: SpecFlagAction) -> Self
Make this flag request help or version output instead of binding a value.
pub fn env(self, env: impl Into<String>) -> Self
Sourcepub fn env_fallback(self, env: impl Into<String>) -> Self
pub fn env_fallback(self, env: impl Into<String>) -> Self
Add an environment variable fallback, consulted in declaration order.
Sourcepub fn deprecated_env(self, env: impl Into<String>) -> Self
pub fn deprecated_env(self, env: impl Into<String>) -> Self
Add a deprecated environment variable alias.
Sourcepub fn deprecated(self, msg: impl Into<String>) -> Self
pub fn deprecated(self, msg: impl Into<String>) -> Self
Set deprecated message
pub fn deprecated_warn_at(self, version: impl Into<String>) -> Self
pub fn deprecated_remove_at(self, version: impl Into<String>) -> Self
Sourcepub fn usage(self, usage: impl Into<String>) -> Self
pub fn usage(self, usage: impl Into<String>) -> Self
Set the rendered usage string. build derives this when unset.
Sourcepub fn help_first_line(self, text: impl Into<String>) -> Self
pub fn help_first_line(self, text: impl Into<String>) -> Self
Set the first line of help text. Derived from help when unset.
Sourcepub fn effect(self, effect: SpecCommandEffect) -> Self
pub fn effect(self, effect: SpecCommandEffect) -> Self
Raise the command’s effect when this flag is supplied.
Trait Implementations§
Source§impl Clone for SpecFlagBuilder
impl Clone for SpecFlagBuilder
Source§fn clone(&self) -> SpecFlagBuilder
fn clone(&self) -> SpecFlagBuilder
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 SpecFlagBuilder
impl Debug for SpecFlagBuilder
Source§impl Default for SpecFlagBuilder
impl Default for SpecFlagBuilder
Source§fn default() -> SpecFlagBuilder
fn default() -> SpecFlagBuilder
Auto Trait Implementations§
impl Freeze for SpecFlagBuilder
impl RefUnwindSafe for SpecFlagBuilder
impl Send for SpecFlagBuilder
impl Sync for SpecFlagBuilder
impl Unpin for SpecFlagBuilder
impl UnsafeUnpin for SpecFlagBuilder
impl UnwindSafe for SpecFlagBuilder
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<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