pub struct CommandSpec {Show 14 fields
pub name: String,
pub short: String,
pub long: Option<String>,
pub aliases: Vec<String>,
pub hidden: bool,
pub system: Option<String>,
pub default_fields: Option<String>,
pub no_auth: bool,
pub auth_provider: Option<String>,
pub tier: Option<Tier>,
pub mutates: bool,
pub auth_metadata: BTreeMap<String, String>,
pub args: Vec<Arg>,
pub output_schema: Option<SchemaInfo>,
}Expand description
Declarative leaf command metadata and parser arguments.
CommandSpec intentionally keeps command metadata next to the command’s
handler. This is the primary copy/paste surface for teams adding commands.
Fields§
§name: StringLeaf command name.
short: StringOne-line command description.
long: Option<String>Optional long help text.
aliases: Vec<String>Alternate command names accepted by the parser.
Whether the command runs but is hidden from help, tree, and search.
system: Option<String>Backend/system id used in output metadata and generic error envelopes.
default_fields: Option<String>Default comma-separated field projection.
no_auth: boolWhether the command bypasses credential resolution.
auth_provider: Option<String>Auth provider name for this command.
tier: Option<Tier>Risk tier used by authentication, authorization, and dry-run.
mutates: boolExplicit dry-run prompt marker for commands without a tier.
auth_metadata: BTreeMap<String, String>Provider-specific auth metadata.
args: Vec<Arg>Command-specific clap arguments.
output_schema: Option<SchemaInfo>Optional output schema published through --schema and help.
Implementations§
Source§impl CommandSpec
impl CommandSpec
Sourcepub fn new(name: impl Into<String>, short: impl Into<String>) -> Self
pub fn new(name: impl Into<String>, short: impl Into<String>) -> Self
Creates a command spec with the required name and one-line help.
Sourcepub fn with_alias(self, alias: impl Into<String>) -> Self
pub fn with_alias(self, alias: impl Into<String>) -> Self
Adds one command alias.
Hides or shows this command in discovery output.
Sourcepub fn with_system(self, system: impl Into<String>) -> Self
pub fn with_system(self, system: impl Into<String>) -> Self
Sets the backend/system id for output metadata and error attribution.
Sourcepub fn with_default_fields(self, default_fields: impl Into<String>) -> Self
pub fn with_default_fields(self, default_fields: impl Into<String>) -> Self
Sets the default field projection used when --fields is absent.
Sourcepub fn with_auth_provider(self, provider: impl Into<String>) -> Self
pub fn with_auth_provider(self, provider: impl Into<String>) -> Self
Selects the auth provider for this command.
Sourcepub fn with_auth_metadata(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_auth_metadata( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Adds provider-specific auth metadata.
Sourcepub fn with_output_schema<T: OutputSchema>(self) -> Self
pub fn with_output_schema<T: OutputSchema>(self) -> Self
Registers a compact framework schema from an OutputSchema type.
Sourcepub fn with_json_schema<T: JsonSchema>(self) -> Self
pub fn with_json_schema<T: JsonSchema>(self) -> Self
Registers JSON Schema generated from a Rust type with schemars.
Sourcepub fn mutates(self, mutates: bool) -> Self
pub fn mutates(self, mutates: bool) -> Self
Marks whether the command should short-circuit under --dry-run.
Sourcepub fn metadata(&self) -> CommandMeta
pub fn metadata(&self) -> CommandMeta
Builds middleware metadata from the spec.
Sourcepub fn clap_command(&self) -> Command
pub fn clap_command(&self) -> Command
Builds the clap command for parser registration.
Trait Implementations§
Source§impl Clone for CommandSpec
impl Clone for CommandSpec
Source§fn clone(&self) -> CommandSpec
fn clone(&self) -> CommandSpec
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more