pub struct CliConfig {Show 18 fields
pub name: String,
pub short: String,
pub long: Option<String>,
pub build: BuildInfo,
pub app_id: String,
pub default_auth_provider: Option<String>,
pub modules: Vec<Module>,
pub commands: Vec<RuntimeCommandSpec>,
pub guides: Vec<GuideEntry>,
pub views: Vec<HumanViewDef>,
pub auth_providers: Vec<Arc<dyn AuthProvider>>,
pub init_deps: Option<InitDeps>,
pub register_flags: Option<RegisterFlags>,
pub apply_flags: Option<ApplyFlags>,
pub pre_run: Option<PreRun>,
pub meta_resolver: Option<ResolveMeta>,
pub on_shutdown: Option<OnShutdown>,
pub extra_search_docs: Option<ExtraSearchDocs>,
}Expand description
Declarative configuration for a CLI application.
Use CliConfig::new for the common path and chain with_* methods for
modules, auth providers, guides, views, and lifecycle hooks. Direct struct
literals remain available for advanced setup and tests.
Fields§
§name: StringRoot command name shown in usage output.
short: StringOne-line root command description.
long: Option<String>Optional longer root command description. Defaults to short.
build: BuildInfoVersion/build metadata for --version.
app_id: StringApplication id stored in middleware and output metadata.
default_auth_provider: Option<String>Fallback auth provider when a command does not select one explicitly.
modules: Vec<Module>Domain modules mounted under the root command.
commands: Vec<RuntimeCommandSpec>Additional top-level runtime commands.
guides: Vec<GuideEntry>Global guide entries mounted under guide.
views: Vec<HumanViewDef>Global human output views.
auth_providers: Vec<Arc<dyn AuthProvider>>Providers registered before command execution starts.
init_deps: Option<InitDeps>Optional late initializer for runtime dependencies.
register_flags: Option<RegisterFlags>Optional hook for adding application-specific global flags.
apply_flags: Option<ApplyFlags>Optional hook for applying parsed application-specific flags.
pre_run: Option<PreRun>Optional hook run before executable commands and built-ins.
meta_resolver: Option<ResolveMeta>Optional hook for global command metadata adjustments.
on_shutdown: Option<OnShutdown>Optional hook called after each run.
extra_search_docs: Option<ExtraSearchDocs>Optional root-scope search document provider.
Implementations§
Source§impl CliConfig
impl CliConfig
Sourcepub fn new(
name: impl Into<String>,
short: impl Into<String>,
app_id: impl Into<String>,
) -> Self
pub fn new( name: impl Into<String>, short: impl Into<String>, app_id: impl Into<String>, ) -> Self
Creates the minimum useful CLI configuration.
Sourcepub fn with_build(self, build: BuildInfo) -> Self
pub fn with_build(self, build: BuildInfo) -> Self
Sets build metadata used by --version.
Sourcepub fn with_default_auth_provider(self, provider: impl Into<String>) -> Self
pub fn with_default_auth_provider(self, provider: impl Into<String>) -> Self
Sets the fallback auth provider for commands that do not name one.
Sourcepub fn with_module(self, module: Module) -> Self
pub fn with_module(self, module: Module) -> Self
Adds one domain module.
Sourcepub fn with_modules(self, modules: impl IntoIterator<Item = Module>) -> Self
pub fn with_modules(self, modules: impl IntoIterator<Item = Module>) -> Self
Adds several domain modules.
Sourcepub fn with_command(self, command: RuntimeCommandSpec) -> Self
pub fn with_command(self, command: RuntimeCommandSpec) -> Self
Adds a top-level runtime command outside a module.
Sourcepub fn with_guide(self, guide: GuideEntry) -> Self
pub fn with_guide(self, guide: GuideEntry) -> Self
Adds one global guide.
Sourcepub fn with_guides(self, guides: impl IntoIterator<Item = GuideEntry>) -> Self
pub fn with_guides(self, guides: impl IntoIterator<Item = GuideEntry>) -> Self
Adds several global guides.
Sourcepub fn with_view(self, view: HumanViewDef) -> Self
pub fn with_view(self, view: HumanViewDef) -> Self
Adds one global human view.
Sourcepub fn with_auth_provider(self, provider: Arc<dyn AuthProvider>) -> Self
pub fn with_auth_provider(self, provider: Arc<dyn AuthProvider>) -> Self
Registers one auth provider.
Sourcepub fn with_init_deps(self, init_deps: InitDeps) -> Self
pub fn with_init_deps(self, init_deps: InitDeps) -> Self
Sets the late dependency initializer.
Sourcepub fn with_register_flags(self, register_flags: RegisterFlags) -> Self
pub fn with_register_flags(self, register_flags: RegisterFlags) -> Self
Sets the application-specific global flag registration hook.
Sourcepub fn with_apply_flags(self, apply_flags: ApplyFlags) -> Self
pub fn with_apply_flags(self, apply_flags: ApplyFlags) -> Self
Sets the application-specific parsed flag application hook.
Sourcepub fn with_pre_run(self, pre_run: PreRun) -> Self
pub fn with_pre_run(self, pre_run: PreRun) -> Self
Sets the pre-run hook.
Sourcepub fn with_meta_resolver(self, meta_resolver: ResolveMeta) -> Self
pub fn with_meta_resolver(self, meta_resolver: ResolveMeta) -> Self
Sets the command metadata resolver hook.
Sourcepub fn with_on_shutdown(self, on_shutdown: OnShutdown) -> Self
pub fn with_on_shutdown(self, on_shutdown: OnShutdown) -> Self
Sets the shutdown hook.
Sourcepub fn with_extra_search_docs(self, extra_search_docs: ExtraSearchDocs) -> Self
pub fn with_extra_search_docs(self, extra_search_docs: ExtraSearchDocs) -> Self
Sets the provider for additional root-scope search documents.