Skip to main content

Module cli

Module cli 

Source
Expand description

High-level CLI entry point that wires together the argot pipeline.

Cli is a batteries-included struct that combines Registry, Parser and the render layer into a single run method. It handles the common built-in behaviors (help, version, empty input) so that application code only needs to build commands and register handlers.

§Example

use std::sync::Arc;
use argot_cmd::{Cli, Command};

let cmd = Command::builder("greet")
    .summary("Say hello")
    .handler(Arc::new(|_| {
        println!("Hello, world!");
        Ok(())
    }))
    .build()
    .unwrap();

let cli = Cli::new(vec![cmd])
    .app_name("myapp")
    .version("1.0.0");

// In a real application:
// cli.run_env_args().unwrap();

Structs§

Cli
A batteries-included entry point that wires together Registry, Parser, and the render layer so callers do not have to do it themselves.

Enums§

CliError
Errors produced by Cli::run.