pub struct SpecFlagBuilder { /* private fields */ }Expand description
Builder for SpecFlag
Implementations§
Source§impl SpecFlagBuilder
impl SpecFlagBuilder
Sourcepub fn new() -> SpecFlagBuilder
pub fn new() -> SpecFlagBuilder
Create a new SpecFlagBuilder
Sourcepub fn name(self, name: impl Into<String>) -> SpecFlagBuilder
pub fn name(self, name: impl Into<String>) -> SpecFlagBuilder
Set the flag name
Sourcepub fn short(self, c: char) -> SpecFlagBuilder
pub fn short(self, c: char) -> SpecFlagBuilder
Add a short flag character (can be called multiple times)
Sourcepub fn shorts(self, chars: impl IntoIterator<Item = char>) -> SpecFlagBuilder
pub fn shorts(self, chars: impl IntoIterator<Item = char>) -> SpecFlagBuilder
Add multiple short flags at once
Sourcepub fn long(self, name: impl Into<String>) -> SpecFlagBuilder
pub fn long(self, name: impl Into<String>) -> SpecFlagBuilder
Add a long flag name (can be called multiple times)
Sourcepub fn longs<I, S>(self, names: I) -> SpecFlagBuilder
pub fn longs<I, S>(self, names: I) -> SpecFlagBuilder
Add multiple long flags at once
Sourcepub fn default_value(self, value: impl Into<String>) -> SpecFlagBuilder
pub fn default_value(self, value: impl Into<String>) -> SpecFlagBuilder
Add a default value (can be called multiple times for var flags)
Sourcepub fn default_values<I, S>(self, values: I) -> SpecFlagBuilder
pub fn default_values<I, S>(self, values: I) -> SpecFlagBuilder
Add multiple default values at once
Sourcepub fn help(self, text: impl Into<String>) -> SpecFlagBuilder
pub fn help(self, text: impl Into<String>) -> SpecFlagBuilder
Set help text
Sourcepub fn help_long(self, text: impl Into<String>) -> SpecFlagBuilder
pub fn help_long(self, text: impl Into<String>) -> SpecFlagBuilder
Set long help text
Sourcepub fn help_md(self, text: impl Into<String>) -> SpecFlagBuilder
pub fn help_md(self, text: impl Into<String>) -> SpecFlagBuilder
Set markdown help text
Sourcepub fn note(self, text: impl Into<String>) -> SpecFlagBuilder
pub fn note(self, text: impl Into<String>) -> SpecFlagBuilder
Add a semantic note rendered in help and generated documentation.
Sourcepub fn warning(self, text: impl Into<String>) -> SpecFlagBuilder
pub fn warning(self, text: impl Into<String>) -> SpecFlagBuilder
Add a semantic warning rendered in help and generated documentation.
Sourcepub fn surface(self, surface: impl Into<String>) -> SpecFlagBuilder
pub fn surface(self, surface: impl Into<String>) -> SpecFlagBuilder
Label the audience or compatibility surface this flag belongs to.
Sourcepub fn available_if(self, condition: impl Into<String>) -> SpecFlagBuilder
pub fn available_if(self, condition: impl Into<String>) -> SpecFlagBuilder
Add a descriptive availability condition.
Sourcepub fn var(self, is_var: bool) -> SpecFlagBuilder
pub fn var(self, is_var: bool) -> SpecFlagBuilder
Set as variadic (can be specified multiple times)
Sourcepub fn var_min(self, min: usize) -> SpecFlagBuilder
pub fn var_min(self, min: usize) -> SpecFlagBuilder
Set minimum count for variadic flag
Sourcepub fn var_max(self, max: usize) -> SpecFlagBuilder
pub fn var_max(self, max: usize) -> SpecFlagBuilder
Set maximum count for variadic flag
Sourcepub fn required(self, is_required: bool) -> SpecFlagBuilder
pub fn required(self, is_required: bool) -> SpecFlagBuilder
Set as required
Sourcepub fn required_if(self, flag: impl Into<String>) -> SpecFlagBuilder
pub fn required_if(self, flag: impl Into<String>) -> SpecFlagBuilder
Add a flag whose presence makes this flag required
Sourcepub fn required_if_any<I, S>(self, flags: I) -> SpecFlagBuilder
pub fn required_if_any<I, S>(self, flags: I) -> SpecFlagBuilder
Add flags whose presence makes this flag required
Sourcepub fn required_if_eq(
self,
selector: impl Into<String>,
value: impl Into<String>,
) -> SpecFlagBuilder
pub fn required_if_eq( self, selector: impl Into<String>, value: impl Into<String>, ) -> SpecFlagBuilder
Add a selector/value condition that makes this flag required.
Sourcepub fn required_if_eq_all<I, S, V>(self, conditions: I) -> SpecFlagBuilder
pub fn required_if_eq_all<I, S, V>(self, conditions: I) -> SpecFlagBuilder
Set selector/value conditions which must all match to require this flag.
Sourcepub fn required_unless(self, flag: impl Into<String>) -> SpecFlagBuilder
pub fn required_unless(self, flag: impl Into<String>) -> SpecFlagBuilder
Add a flag whose absence makes this flag required
Sourcepub fn required_unless_any<I, S>(self, flags: I) -> SpecFlagBuilder
pub fn required_unless_any<I, S>(self, flags: I) -> SpecFlagBuilder
Add flags where the absence of all of them makes this flag required
Sourcepub fn required_unless_all<I, S>(self, flags: I) -> SpecFlagBuilder
pub fn required_unless_all<I, S>(self, flags: I) -> SpecFlagBuilder
Add selectors which must all be present to waive this flag’s requirement.
Sourcepub fn global(self, is_global: bool) -> SpecFlagBuilder
pub fn global(self, is_global: bool) -> SpecFlagBuilder
Set as global (available to subcommands)
Sourcepub fn hide(self, is_hidden: bool) -> SpecFlagBuilder
pub fn hide(self, is_hidden: bool) -> SpecFlagBuilder
Set as hidden
Sourcepub fn count(self, is_count: bool) -> SpecFlagBuilder
pub fn count(self, is_count: bool) -> SpecFlagBuilder
Set as count flag
Sourcepub fn allow_hyphen_values(self, allow: bool) -> SpecFlagBuilder
pub fn allow_hyphen_values(self, allow: bool) -> SpecFlagBuilder
Allow this flag’s value to start with -
Sourcepub fn require_equals(self, require: bool) -> SpecFlagBuilder
pub fn require_equals(self, require: bool) -> SpecFlagBuilder
Require --flag=value and refuse --flag value.
Sourcepub fn value_optional(self, optional: bool) -> SpecFlagBuilder
pub fn value_optional(self, optional: bool) -> SpecFlagBuilder
Allow this flag to be present without a value.
Sourcepub fn bool_value(self, enabled: bool) -> SpecFlagBuilder
pub fn bool_value(self, enabled: bool) -> SpecFlagBuilder
Allow --flag=true and --flag=false on a boolean switch.
Sourcepub fn default_missing(self, value: impl Into<String>) -> SpecFlagBuilder
pub fn default_missing(self, value: impl Into<String>) -> SpecFlagBuilder
Value used when the flag is present but no value is given.
Sourcepub fn arg(self, arg: SpecArg) -> SpecFlagBuilder
pub fn arg(self, arg: SpecArg) -> SpecFlagBuilder
Set the argument spec for flags that take values
Sourcepub fn negate(self, negate: impl Into<String>) -> SpecFlagBuilder
pub fn negate(self, negate: impl Into<String>) -> SpecFlagBuilder
Set negate string
Sourcepub fn override_with(self, flag: impl Into<String>) -> SpecFlagBuilder
pub fn override_with(self, flag: impl Into<String>) -> SpecFlagBuilder
Add a flag that this flag mutually overrides
Sourcepub fn overrides_with<I, S>(self, flags: I) -> SpecFlagBuilder
pub fn overrides_with<I, S>(self, flags: I) -> SpecFlagBuilder
Add flags that this flag mutually overrides
Sourcepub fn require(self, flag: impl Into<String>) -> SpecFlagBuilder
pub fn require(self, flag: impl Into<String>) -> SpecFlagBuilder
Add a flag that must also be given when this one is
Sourcepub fn requires<I, S>(self, flags: I) -> SpecFlagBuilder
pub fn requires<I, S>(self, flags: I) -> SpecFlagBuilder
Add flags that must also be given when this one is
Sourcepub fn requires_if(
self,
value: impl Into<String>,
flag: impl Into<String>,
) -> SpecFlagBuilder
pub fn requires_if( self, value: impl Into<String>, flag: impl Into<String>, ) -> SpecFlagBuilder
Add a flag required when this flag is explicitly given value
Sourcepub fn requires_ifs<I, V, S>(self, requirements: I) -> SpecFlagBuilder
pub fn requires_ifs<I, V, S>(self, requirements: I) -> SpecFlagBuilder
Add value-conditional flag requirements
Sourcepub fn default_if(
self,
selector: impl Into<String>,
value: impl Into<String>,
) -> SpecFlagBuilder
pub fn default_if( self, selector: impl Into<String>, value: impl Into<String>, ) -> SpecFlagBuilder
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>,
) -> SpecFlagBuilder
pub fn default_if_eq( self, selector: impl Into<String>, when: impl Into<String>, value: impl Into<String>, ) -> SpecFlagBuilder
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) -> SpecFlagBuilderwhere
I: IntoIterator<Item = SpecDefaultIf>,
pub fn default_ifs<I>(self, conditions: I) -> SpecFlagBuilderwhere
I: IntoIterator<Item = SpecDefaultIf>,
Add several conditional defaults, in first-match-wins order.
Sourcepub fn help_heading(self, help_heading: impl Into<String>) -> SpecFlagBuilder
pub fn help_heading(self, help_heading: impl Into<String>) -> SpecFlagBuilder
Heading to list this under in help output.
Sourcepub fn action(self, action: SpecFlagAction) -> SpecFlagBuilder
pub fn action(self, action: SpecFlagAction) -> SpecFlagBuilder
Make this flag request help or version output instead of binding a value.
pub fn env(self, env: impl Into<String>) -> SpecFlagBuilder
Sourcepub fn env_fallback(self, env: impl Into<String>) -> SpecFlagBuilder
pub fn env_fallback(self, env: impl Into<String>) -> SpecFlagBuilder
Add an environment variable fallback, consulted in declaration order.
Sourcepub fn deprecated_env(self, env: impl Into<String>) -> SpecFlagBuilder
pub fn deprecated_env(self, env: impl Into<String>) -> SpecFlagBuilder
Add a deprecated environment variable alias.
Sourcepub fn deprecated(self, msg: impl Into<String>) -> SpecFlagBuilder
pub fn deprecated(self, msg: impl Into<String>) -> SpecFlagBuilder
Set deprecated message
pub fn deprecated_warn_at(self, version: impl Into<String>) -> SpecFlagBuilder
pub fn deprecated_remove_at(self, version: impl Into<String>) -> SpecFlagBuilder
Sourcepub fn usage(self, usage: impl Into<String>) -> SpecFlagBuilder
pub fn usage(self, usage: impl Into<String>) -> SpecFlagBuilder
Set the rendered usage string. build derives this when unset.
Sourcepub fn help_first_line(self, text: impl Into<String>) -> SpecFlagBuilder
pub fn help_first_line(self, text: impl Into<String>) -> SpecFlagBuilder
Set the first line of help text. Derived from help when unset.
Sourcepub fn effect(self, effect: SpecCommandEffect) -> SpecFlagBuilder
pub fn effect(self, effect: SpecCommandEffect) -> SpecFlagBuilder
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