pub struct CommandSpec {
pub name: String,
pub about: Option<String>,
pub aliases: Vec<String>,
pub options: Vec<OptionSpec>,
pub positionals: Vec<PositionalSpec>,
pub subcommands: Vec<CommandSpec>,
pub subcommand_required: bool,
pub after_help: Option<String>,
pub stability: Stability,
}Expand description
A command and (recursively) its subcommands. The single source consumed by the parser, the help renderer, and the completion-tree builder.
Fields§
§name: String§about: Option<String>§aliases: Vec<String>§options: Vec<OptionSpec>§positionals: Vec<PositionalSpec>§subcommands: Vec<CommandSpec>§subcommand_required: boolWhen true, a subcommand must be given (a group command).
after_help: Option<String>Free-form text appended after the options block in --help (examples,
notes). From #[command(after_help/after_long_help = …)].
stability: StabilityMaturity tier (see crate::Stability) — governs whether this command is
offered during completion. From #[command(stability = "…")]. Defaults
to Stable.
Implementations§
Source§impl CommandSpec
impl CommandSpec
pub fn new(name: impl Into<String>) -> Self
pub fn about(self, a: impl Into<String>) -> Self
Sourcepub fn alias(self, a: impl Into<String>) -> Self
pub fn alias(self, a: impl Into<String>) -> Self
Add an alternate name this command also answers to (e.g. ls for list).
pub fn after_help(self, a: impl Into<String>) -> Self
Sourcepub fn stability(self, s: Stability) -> Self
pub fn stability(self, s: Stability) -> Self
Declare this command’s maturity tier (see crate::Stability).
pub fn option(self, o: OptionSpec) -> Self
pub fn positional(self, p: PositionalSpec) -> Self
pub fn subcommand(self, c: CommandSpec) -> Self
Trait Implementations§
Source§impl Clone for CommandSpec
impl Clone for CommandSpec
Source§fn clone(&self) -> CommandSpec
fn clone(&self) -> CommandSpec
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CommandSpec
impl Debug for CommandSpec
Source§impl Default for CommandSpec
impl Default for CommandSpec
Source§fn default() -> CommandSpec
fn default() -> CommandSpec
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for CommandSpec
impl !UnwindSafe for CommandSpec
impl Freeze for CommandSpec
impl Send for CommandSpec
impl Sync for CommandSpec
impl Unpin for CommandSpec
impl UnsafeUnpin for CommandSpec
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