pub struct SpecCommand {Show 24 fields
pub full_cmd: Vec<String>,
pub usage: String,
pub subcommands: IndexMap<String, SpecCommand>,
pub args: Vec<SpecArg>,
pub flags: Vec<SpecFlag>,
pub mounts: Vec<SpecMount>,
pub deprecated: Option<String>,
pub hide: bool,
pub subcommand_required: bool,
pub restart_token: Option<String>,
pub help: Option<String>,
pub help_long: Option<String>,
pub help_md: Option<String>,
pub name: String,
pub aliases: Vec<String>,
pub hidden_aliases: Vec<String>,
pub before_help: Option<String>,
pub before_help_long: Option<String>,
pub before_help_md: Option<String>,
pub after_help: Option<String>,
pub after_help_long: Option<String>,
pub after_help_md: Option<String>,
pub examples: Vec<SpecExample>,
pub complete: IndexMap<String, SpecComplete>,
/* private fields */
}Expand description
A CLI command or subcommand specification.
Commands define the structure of a CLI, including their flags, arguments, and nested subcommands. The root command represents the main CLI entry point.
§Example
use usage::{SpecCommand, SpecFlag, SpecArg};
let cmd = SpecCommand::builder()
.name("install")
.help("Install a package")
.alias("i")
.flag(SpecFlag::builder().short('f').long("force").build())
.arg(SpecArg::builder().name("package").required(true).build())
.build();Fields§
§full_cmd: Vec<String>Full command path from root (e.g., [“git”, “remote”, “add”])
usage: StringGenerated usage string
subcommands: IndexMap<String, SpecCommand>Nested subcommands indexed by name
args: Vec<SpecArg>Positional arguments for this command
flags: Vec<SpecFlag>Flags/options for this command
mounts: Vec<SpecMount>Mounted external specs
deprecated: Option<String>Deprecation message if this command is deprecated
hide: boolWhether to hide this command from help output
subcommand_required: boolWhether a subcommand must be provided
restart_token: Option<String>Token that resets argument parsing, allowing multiple command invocations.
e.g., mise run lint ::: test ::: check with restart_token=“:::”
help: Option<String>Short help text shown in command listings
help_long: Option<String>Extended help text shown with –help
help_md: Option<String>Markdown-formatted help text
name: StringCommand name (e.g., “install”)
aliases: Vec<String>Alternative names for this command
Hidden alternative names (not shown in help)
before_help: Option<String>Text displayed before the help content
before_help_long: Option<String>Extended text displayed before help content
before_help_md: Option<String>Markdown text displayed before help content
after_help: Option<String>Text displayed after the help content
after_help_long: Option<String>Extended text displayed after help content
after_help_md: Option<String>Markdown text displayed after help content
examples: Vec<SpecExample>Usage examples for this command
complete: IndexMap<String, SpecComplete>Custom completers for arguments
Implementations§
Source§impl SpecCommand
impl SpecCommand
Sourcepub fn builder() -> SpecCommandBuilder
pub fn builder() -> SpecCommandBuilder
Create a new builder for SpecCommand
pub fn usage(&self) -> String
pub fn all_subcommands(&self) -> Vec<&SpecCommand>
pub fn find_subcommand(&self, name: &str) -> Option<&SpecCommand>
Trait Implementations§
Source§impl Clone for SpecCommand
impl Clone for SpecCommand
Source§fn clone(&self) -> SpecCommand
fn clone(&self) -> SpecCommand
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SpecCommand
impl Debug for SpecCommand
Source§impl Default for SpecCommand
impl Default for SpecCommand
Source§impl From<&SpecCommand> for KdlNode
impl From<&SpecCommand> for KdlNode
Source§fn from(cmd: &SpecCommand) -> Self
fn from(cmd: &SpecCommand) -> Self
Auto Trait Implementations§
impl !Freeze for SpecCommand
impl RefUnwindSafe for SpecCommand
impl Send for SpecCommand
impl Sync for SpecCommand
impl Unpin for SpecCommand
impl UnwindSafe for SpecCommand
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