#[non_exhaustive]pub struct Module {
pub category: String,
pub guides: Vec<GuideEntry>,
pub views: Vec<HumanViewDef>,
pub feature_flag: Option<FeatureFlag>,
pub register: ModuleRegister,
}Expand description
Domain-bounded unit of CLI functionality.
A module usually maps to a product, platform, resource family, or team ownership boundary. It contributes one top-level group plus optional guides and human output views.
Construct with Module::new, then chain with_* methods — never as a
struct literal. #[non_exhaustive] enforces this so the engine can add
fields 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.category: StringRoot help category.
guides: Vec<GuideEntry>Guide entries merged into the CLI-wide guide command.
views: Vec<HumanViewDef>Human output views registered before command execution.
feature_flag: Option<FeatureFlag>This module’s own feature-flag declaration, if any.
None means the module has no explicit stage declaration of its own,
in which case its group and descendants inherit their effective stage
from their nearest ancestor (nested group, then 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. A module is
the top-level ancestor in that chain: nothing sits above it. Set with
with_feature_flag. This field only
records the module’s own declaration; cascading resolution (and
pruning of nodes the active FlagPolicy hides)
happens when a Cli mounts this module via
Cli::add_module.
register: ModuleRegisterRegistration function that returns the module’s runtime group.
Implementations§
Source§impl Module
impl Module
Sourcepub fn new<F>(category: impl Into<String>, register: F) -> Self
pub fn new<F>(category: impl Into<String>, register: F) -> Self
Creates a closure-based module.
Sourcepub fn from_command_module<M>(module: M) -> Selfwhere
M: CommandModule,
pub fn from_command_module<M>(module: M) -> Selfwhere
M: CommandModule,
Converts a trait-based module into the runtime module type.
Sourcepub fn with_guide(self, guide: GuideEntry) -> Self
pub fn with_guide(self, guide: GuideEntry) -> Self
Adds one guide entry.
Sourcepub fn with_guides(self, guides: impl IntoIterator<Item = GuideEntry>) -> Self
pub fn with_guides(self, guides: impl IntoIterator<Item = GuideEntry>) -> Self
Adds several guide entries.
Sourcepub fn with_guides_from_markdown(
self,
files: impl IntoIterator<Item = (impl AsRef<Path>, impl AsRef<[u8]>)>,
) -> Self
pub fn with_guides_from_markdown( self, files: impl IntoIterator<Item = (impl AsRef<Path>, impl AsRef<[u8]>)>, ) -> Self
Parses markdown guide entries from embedded (path, bytes) pairs.
Sourcepub fn with_view(self, view: HumanViewDef) -> Self
pub fn with_view(self, view: HumanViewDef) -> Self
Adds one human output view.
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 module’s own feature flag: the key used for policy overrides and introspection, and the stage at which it becomes visible.