pub struct Cli { /* private fields */ }Expand description
Configured CLI application.
A Cli owns the clap command tree, middleware, registered runtime
commands, guides, schemas, and built-ins. Consumer binaries normally create
one Cli and call Cli::execute.
Implementations§
Source§impl Cli
impl Cli
Sourcepub fn middleware(&self) -> &Middleware
pub fn middleware(&self) -> &Middleware
Returns the shared middleware template.
Sourcepub fn middleware_mut(&mut self) -> &mut Middleware
pub fn middleware_mut(&mut self) -> &mut Middleware
Returns mutable middleware for advanced application setup.
Sourcepub async fn execute(&self) -> ExitCode
pub async fn execute(&self) -> ExitCode
Executes the CLI with process arguments and process stdout/stderr.
Sourcepub async fn execute_from<I, S, O, E>(
&self,
args: I,
stdout: &mut O,
stderr: &mut E,
) -> Result<ExitCode>
pub async fn execute_from<I, S, O, E>( &self, args: I, stdout: &mut O, stderr: &mut E, ) -> Result<ExitCode>
Executes the CLI with caller-provided args and output writers.
Sourcepub async fn execute_from_until_signal<I, S, O, E, Shutdown>(
&self,
args: I,
stdout: &mut O,
stderr: &mut E,
shutdown: Shutdown,
) -> Result<ExitCode>
pub async fn execute_from_until_signal<I, S, O, E, Shutdown>( &self, args: I, stdout: &mut O, stderr: &mut E, shutdown: Shutdown, ) -> Result<ExitCode>
Executes the CLI until either command completion or a shutdown signal future resolves.
Sourcepub fn register_auth_provider(
&mut self,
provider: Arc<dyn AuthProvider>,
) -> &mut Self
pub fn register_auth_provider( &mut self, provider: Arc<dyn AuthProvider>, ) -> &mut Self
Registers an auth provider after construction.
Sourcepub fn root_command(&self) -> &Command
pub fn root_command(&self) -> &Command
Returns the built clap root command.
Sourcepub fn add_module_group(
&mut self,
category: impl Into<String>,
group: RuntimeGroupSpec,
) -> &mut Self
pub fn add_module_group( &mut self, category: impl Into<String>, group: RuntimeGroupSpec, ) -> &mut Self
Adds one runtime module group after construction.
Sourcepub fn add_module(&mut self, module: Module) -> &mut Self
pub fn add_module(&mut self, module: Module) -> &mut Self
Adds one module after construction.
Sourcepub fn add_command(&mut self, command: RuntimeCommandSpec) -> &mut Self
pub fn add_command(&mut self, command: RuntimeCommandSpec) -> &mut Self
Adds one top-level runtime command after construction.
Sourcepub fn set_has_guide(&mut self, has_guide: bool) -> &mut Self
pub fn set_has_guide(&mut self, has_guide: bool) -> &mut Self
Controls whether the built-in guide command is advertised.
Sourcepub fn add_guides(
&mut self,
entries: impl IntoIterator<Item = GuideEntry>,
) -> &mut Self
pub fn add_guides( &mut self, entries: impl IntoIterator<Item = GuideEntry>, ) -> &mut Self
Adds guide entries after construction.
Sourcepub async fn run<I, S>(&self, args: I) -> CliRunOutput
pub async fn run<I, S>(&self, args: I) -> CliRunOutput
Runs the CLI with provided args and captures the rendered result.