Skip to main content

CliConfig

Struct CliConfig 

Source
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: String

Root command name shown in usage output.

§short: String

One-line root command description.

§long: Option<String>

Optional longer root command description. Defaults to short.

§build: BuildInfo

Version/build metadata for --version.

§app_id: String

Application 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

Source

pub fn new( name: impl Into<String>, short: impl Into<String>, app_id: impl Into<String>, ) -> Self

Creates the minimum useful CLI configuration.

Source

pub fn with_long(self, long: impl Into<String>) -> Self

Sets root long help text.

Source

pub fn with_build(self, build: BuildInfo) -> Self

Sets build metadata used by --version.

Source

pub fn with_default_auth_provider(self, provider: impl Into<String>) -> Self

Sets the fallback auth provider for commands that do not name one.

Source

pub fn with_module(self, module: Module) -> Self

Adds one domain module.

Source

pub fn with_modules(self, modules: impl IntoIterator<Item = Module>) -> Self

Adds several domain modules.

Source

pub fn with_command(self, command: RuntimeCommandSpec) -> Self

Adds a top-level runtime command outside a module.

Source

pub fn with_guide(self, guide: GuideEntry) -> Self

Adds one global guide.

Source

pub fn with_guides(self, guides: impl IntoIterator<Item = GuideEntry>) -> Self

Adds several global guides.

Source

pub fn with_view(self, view: HumanViewDef) -> Self

Adds one global human view.

Source

pub fn with_auth_provider(self, provider: Arc<dyn AuthProvider>) -> Self

Registers one auth provider.

Source

pub fn with_init_deps(self, init_deps: InitDeps) -> Self

Sets the late dependency initializer.

Source

pub fn with_register_flags(self, register_flags: RegisterFlags) -> Self

Sets the application-specific global flag registration hook.

Source

pub fn with_apply_flags(self, apply_flags: ApplyFlags) -> Self

Sets the application-specific parsed flag application hook.

Source

pub fn with_pre_run(self, pre_run: PreRun) -> Self

Sets the pre-run hook.

Source

pub fn with_meta_resolver(self, meta_resolver: ResolveMeta) -> Self

Sets the command metadata resolver hook.

Source

pub fn with_on_shutdown(self, on_shutdown: OnShutdown) -> Self

Sets the shutdown hook.

Source

pub fn with_extra_search_docs(self, extra_search_docs: ExtraSearchDocs) -> Self

Sets the provider for additional root-scope search documents.

Trait Implementations§

Source§

impl Clone for CliConfig

Source§

fn clone(&self) -> CliConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CliConfig

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CliConfig

Source§

fn default() -> CliConfig

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more