pub struct CliApp { /* private fields */ }Expand description
Built CLI/REPL application
Created by CliBuilder::build(). Provides methods to run the application
in different modes:
run()- Auto-detect CLI vs REPL based on argumentsrun_cli()- Force CLI mode with specific argumentsrun_repl()- Force REPL mode
§Example
use dynamic_cli::prelude::*;
let app = CliBuilder::new()
.config_file("commands.yaml")
.context(Box::new(MyContext::default()))
.register_sync_handler("handler", Box::new(MyHandler))
.build()?;
// Auto-detect mode (CLI if args provided, REPL otherwise)
app.run()Implementations§
Source§impl CliApp
impl CliApp
Sourcepub fn run_cli(self, args: Vec<String>) -> Result<()>
pub fn run_cli(self, args: Vec<String>) -> Result<()>
Run in CLI mode with provided arguments
Executes a single command and exits.
§Arguments
args- Command-line arguments (typically fromenv::args().skip(1))
§Returns
Ok(())on successful executionErr(...)on parse, validation, or execution errors
§Example
// Run with specific arguments
app.run_cli(vec!["command".to_string(), "arg1".to_string()])Sourcepub fn run(self) -> Result<()>
pub fn run(self) -> Result<()>
Run with automatic mode detection
Decides between CLI and REPL based on command-line arguments:
- If arguments provided → CLI mode
- If no arguments → REPL mode
This is the recommended method for most applications.
§Returns
Ok(())on successful executionErr(...)on errors
§Example
// Auto-detect: CLI if args, REPL if no args
app.run()Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for CliApp
impl !Send for CliApp
impl !Sync for CliApp
impl !UnwindSafe for CliApp
impl Freeze for CliApp
impl Unpin for CliApp
impl UnsafeUnpin for CliApp
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more