pub struct SpecArgBuilder { /* private fields */ }Expand description
Builder for SpecArg
Implementations§
Source§impl SpecArgBuilder
impl SpecArgBuilder
Sourcepub fn new() -> SpecArgBuilder
pub fn new() -> SpecArgBuilder
Create a new SpecArgBuilder
Sourcepub fn surface(self, surface: impl Into<String>) -> SpecArgBuilder
pub fn surface(self, surface: impl Into<String>) -> SpecArgBuilder
Label the audience or compatibility surface this argument belongs to.
Sourcepub fn available_if(self, condition: impl Into<String>) -> SpecArgBuilder
pub fn available_if(self, condition: impl Into<String>) -> SpecArgBuilder
Add a descriptive availability condition.
Sourcepub fn name(self, name: impl Into<String>) -> SpecArgBuilder
pub fn name(self, name: impl Into<String>) -> SpecArgBuilder
Set the argument name
Sourcepub fn sigil(self, sigil: impl Into<String>) -> SpecArgBuilder
pub fn sigil(self, sigil: impl Into<String>) -> SpecArgBuilder
Classify this positional by a leading token prefix and strip it on binding.
Sourcepub fn value_names<I, S>(self, names: I) -> SpecArgBuilder
pub fn value_names<I, S>(self, names: I) -> SpecArgBuilder
Set the ordered placeholders for a fixed-arity value.
Sourcepub fn default_value(self, value: impl Into<String>) -> SpecArgBuilder
pub fn default_value(self, value: impl Into<String>) -> SpecArgBuilder
Add a default value (can be called multiple times for var args)
Sourcepub fn default_values<I, S>(self, values: I) -> SpecArgBuilder
pub fn default_values<I, S>(self, values: I) -> SpecArgBuilder
Add multiple default values at once
Sourcepub fn help(self, text: impl Into<String>) -> SpecArgBuilder
pub fn help(self, text: impl Into<String>) -> SpecArgBuilder
Set help text
Sourcepub fn help_long(self, text: impl Into<String>) -> SpecArgBuilder
pub fn help_long(self, text: impl Into<String>) -> SpecArgBuilder
Set long help text
Sourcepub fn help_md(self, text: impl Into<String>) -> SpecArgBuilder
pub fn help_md(self, text: impl Into<String>) -> SpecArgBuilder
Set markdown help text
Sourcepub fn note(self, text: impl Into<String>) -> SpecArgBuilder
pub fn note(self, text: impl Into<String>) -> SpecArgBuilder
Add a semantic note rendered in help and generated documentation.
Sourcepub fn warning(self, text: impl Into<String>) -> SpecArgBuilder
pub fn warning(self, text: impl Into<String>) -> SpecArgBuilder
Add a semantic warning rendered in help and generated documentation.
Sourcepub fn var(self, is_var: bool) -> SpecArgBuilder
pub fn var(self, is_var: bool) -> SpecArgBuilder
Set as variadic (accepts multiple values)
Sourcepub fn var_min(self, min: usize) -> SpecArgBuilder
pub fn var_min(self, min: usize) -> SpecArgBuilder
Set minimum count for variadic argument
Sourcepub fn var_max(self, max: usize) -> SpecArgBuilder
pub fn var_max(self, max: usize) -> SpecArgBuilder
Set maximum count for variadic argument
Sourcepub fn required(self, is_required: bool) -> SpecArgBuilder
pub fn required(self, is_required: bool) -> SpecArgBuilder
Set as required
Sourcepub fn requires<I, S>(self, selectors: I) -> SpecArgBuilder
pub fn requires<I, S>(self, selectors: I) -> SpecArgBuilder
Add arguments that must be satisfied when this positional is present.
Sourcepub fn required_if_any<I, S>(self, selectors: I) -> SpecArgBuilder
pub fn required_if_any<I, S>(self, selectors: I) -> SpecArgBuilder
Add selectors whose presence makes this positional required.
Sourcepub fn required_if_eq(
self,
selector: impl Into<String>,
value: impl Into<String>,
) -> SpecArgBuilder
pub fn required_if_eq( self, selector: impl Into<String>, value: impl Into<String>, ) -> SpecArgBuilder
Add a selector/value condition that makes this positional required.
Sourcepub fn required_if_eq_all<I, S, V>(self, conditions: I) -> SpecArgBuilder
pub fn required_if_eq_all<I, S, V>(self, conditions: I) -> SpecArgBuilder
Set selector/value conditions which must all match to require this positional.
Sourcepub fn required_unless_any<I, S>(self, selectors: I) -> SpecArgBuilder
pub fn required_unless_any<I, S>(self, selectors: I) -> SpecArgBuilder
Add selectors where any presence waives this positional’s requirement.
Sourcepub fn required_unless_all<I, S>(self, selectors: I) -> SpecArgBuilder
pub fn required_unless_all<I, S>(self, selectors: I) -> SpecArgBuilder
Add selectors which must all be present to waive this positional’s requirement.
Sourcepub fn hide(self, is_hidden: bool) -> SpecArgBuilder
pub fn hide(self, is_hidden: bool) -> SpecArgBuilder
Set as hidden
Sourcepub fn help_heading(self, help_heading: impl Into<String>) -> SpecArgBuilder
pub fn help_heading(self, help_heading: impl Into<String>) -> SpecArgBuilder
Set environment variable name Heading to list this under in help output.
pub fn env(self, env: impl Into<String>) -> SpecArgBuilder
Sourcepub fn env_fallback(self, env: impl Into<String>) -> SpecArgBuilder
pub fn env_fallback(self, env: impl Into<String>) -> SpecArgBuilder
Add an environment fallback, consulted after the canonical variable.
Sourcepub fn deprecated_env(self, env: impl Into<String>) -> SpecArgBuilder
pub fn deprecated_env(self, env: impl Into<String>) -> SpecArgBuilder
Add a deprecated environment alias, consulted after ordinary fallbacks.
Sourcepub fn double_dash(self, behavior: SpecDoubleDashChoices) -> SpecArgBuilder
pub fn double_dash(self, behavior: SpecDoubleDashChoices) -> SpecArgBuilder
Set the double-dash behavior
Sourcepub fn choices<I, S>(self, choices: I) -> SpecArgBuilder
pub fn choices<I, S>(self, choices: I) -> SpecArgBuilder
Set choices for this argument
Sourcepub fn validate(self, expression: impl Into<String>) -> SpecArgBuilder
pub fn validate(self, expression: impl Into<String>) -> SpecArgBuilder
Set a portable expr expression that must accept each raw value.
Sourcepub fn validate_error(self, message: impl Into<String>) -> SpecArgBuilder
pub fn validate_error(self, message: impl Into<String>) -> SpecArgBuilder
Set the message reported when validation returns false.
Sourcepub fn choices_run(self, run: impl Into<String>) -> SpecArgBuilder
pub fn choices_run(self, run: impl Into<String>) -> SpecArgBuilder
Take further choices from the lines a shell command prints (choices run=).
The command runs when a value is checked, a word is completed, or a running program shows its help; generated docs and code describe it without running it.
Sourcepub fn usage(self, usage: impl Into<String>) -> SpecArgBuilder
pub fn usage(self, usage: impl Into<String>) -> SpecArgBuilder
Set the rendered usage string. build derives this when unset.
Sourcepub fn help_first_line(self, text: impl Into<String>) -> SpecArgBuilder
pub fn help_first_line(self, text: impl Into<String>) -> SpecArgBuilder
Set the first line of help text. Derived from help when unset.
Sourcepub fn effect(self, effect: SpecCommandEffect) -> SpecArgBuilder
pub fn effect(self, effect: SpecCommandEffect) -> SpecArgBuilder
Raise the command’s effect when this argument is supplied.
Sourcepub fn complete(self, complete: SpecComplete) -> SpecArgBuilder
pub fn complete(self, complete: SpecComplete) -> SpecArgBuilder
Attach a completer to this argument itself, the builder form of a complete node
written inside arg. It wins over a complete found by name. build sets the
completer’s name to the argument’s, lowercased, replacing any name it was given.
Trait Implementations§
Source§impl Clone for SpecArgBuilder
impl Clone for SpecArgBuilder
Source§fn clone(&self) -> SpecArgBuilder
fn clone(&self) -> SpecArgBuilder
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 SpecArgBuilder
impl Debug for SpecArgBuilder
Source§impl Default for SpecArgBuilder
impl Default for SpecArgBuilder
Source§fn default() -> SpecArgBuilder
fn default() -> SpecArgBuilder
Auto Trait Implementations§
impl Freeze for SpecArgBuilder
impl RefUnwindSafe for SpecArgBuilder
impl Send for SpecArgBuilder
impl Sync for SpecArgBuilder
impl Unpin for SpecArgBuilder
impl UnsafeUnpin for SpecArgBuilder
impl UnwindSafe for SpecArgBuilder
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