pub struct CommandBuilder<'r, 'a> { /* private fields */ }Expand description
Fluent builder for registering a command with typed arguments.
Implementations§
Source§impl<'r, 'a> CommandBuilder<'r, 'a>
impl<'r, 'a> CommandBuilder<'r, 'a>
Sourcepub fn description(self, desc: &str) -> Self
pub fn description(self, desc: &str) -> Self
Sets the command description (shown in /help).
Sourcepub fn arg(self, name: &str, arg_type: Arg) -> Self
pub fn arg(self, name: &str, arg_type: Arg) -> Self
Adds a required argument with default validation.
Sourcepub fn arg_with(self, name: &str, arg_type: Arg, validation: Validation) -> Self
pub fn arg_with(self, name: &str, arg_type: Arg, validation: Validation) -> Self
Adds a required argument with custom validation.
Sourcepub fn optional_arg(self, name: &str, arg_type: Arg) -> Self
pub fn optional_arg(self, name: &str, arg_type: Arg) -> Self
Adds an optional argument with default validation.
Sourcepub fn variant(
self,
build: impl FnOnce(VariantBuilder) -> VariantBuilder,
) -> Self
pub fn variant( self, build: impl FnOnce(VariantBuilder) -> VariantBuilder, ) -> Self
Adds a variant for polymorphic commands.
Each variant is a separate argument list. The parser tries variants in order and uses the first one that succeeds.
Auto Trait Implementations§
impl<'r, 'a> Freeze for CommandBuilder<'r, 'a>
impl<'r, 'a> !RefUnwindSafe for CommandBuilder<'r, 'a>
impl<'r, 'a> !Send for CommandBuilder<'r, 'a>
impl<'r, 'a> !Sync for CommandBuilder<'r, 'a>
impl<'r, 'a> Unpin for CommandBuilder<'r, 'a>
impl<'r, 'a> UnsafeUnpin for CommandBuilder<'r, 'a>
impl<'r, 'a> !UnwindSafe for CommandBuilder<'r, 'a>
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
Mutably borrows from an owned value. Read more