#[non_exhaustive]pub struct GroupSpec {
pub name: String,
pub short: String,
pub long: Option<String>,
pub aliases: Vec<String>,
pub hidden: bool,
pub commands: Vec<CommandSpec>,
pub groups: Vec<GroupSpec>,
pub feature_flag: Option<FeatureFlag>,
}Expand description
Declarative command group metadata.
Groups are noun-based containers. They do not run business logic directly; when invoked bare, the CLI renders group help.
Construct with GroupSpec::new, then configure with the with_* builder
methods — never as a struct literal. #[non_exhaustive] enforces this so
the engine can add fields later without a breaking release.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.name: StringGroup command name.
short: StringOne-line group description.
long: Option<String>Optional long help text.
aliases: Vec<String>Alternate group names accepted by the parser.
Whether the group runs but is hidden from discovery output.
commands: Vec<CommandSpec>Declarative child commands used for static tree construction.
groups: Vec<GroupSpec>Declarative nested groups used for static tree construction.
feature_flag: Option<FeatureFlag>This group’s own feature-flag declaration, if any.
None means the group has no explicit stage declaration of its own, in
which case it inherits its effective stage from its nearest ancestor
(enclosing group, then module — nearest declaration wins), implicitly
resolving to Stage::Ga if nothing in the ancestor chain declares a
flag either; see Stage’s documentation for why that is its default.
Set with with_feature_flag. This field
only records the group’s own declaration; cascading resolution against
the ancestor chain happens when a Cli mounts the
enclosing module or parent group.
Implementations§
Source§impl GroupSpec
impl GroupSpec
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 group 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 group alias.
Hides or shows this group in discovery output.
Sourcepub fn with_command(self, command: CommandSpec) -> Self
pub fn with_command(self, command: CommandSpec) -> Self
Adds one declarative child command.
Sourcepub fn with_group(self, group: GroupSpec) -> Self
pub fn with_group(self, group: GroupSpec) -> Self
Adds one declarative nested group.
Sourcepub fn with_feature_flag(self, key: impl Into<String>, stage: Stage) -> Self
pub fn with_feature_flag(self, key: impl Into<String>, stage: Stage) -> Self
Declares this group’s own feature flag: the key used for policy overrides and introspection, and the stage at which it becomes visible.
Sourcepub fn clap_command(&self) -> Command
pub fn clap_command(&self) -> Command
Builds the clap command for parser registration.