bootstrap_cli

Function bootstrap_cli 

Source
pub fn bootstrap_cli() -> Result<ValidatedCli, ParseError>
Expand description

Bootstrap and parse CLI arguments

This is the main entry point for the bootstrap layer. It handles:

  1. CLI parsing with clap
  2. Security validation
  3. Returns validated configuration

The caller is responsible for:

  • Running the application logic
  • Mapping results to exit codes using result_to_exit_code

§Returns

ValidatedCli with all arguments security-checked and validated

§Errors

Returns cli::ParseError if CLI parsing or validation fails. Clap will handle –help and –version automatically and exit the process.

§Example

use adaptive_pipeline_bootstrap::{bootstrap_cli, result_to_exit_code};

#[tokio::main]
async fn main() -> std::process::ExitCode {
    // Parse and validate CLI
    let validated_cli = match bootstrap_cli() {
        Ok(cli) => cli,
        Err(e) => {
            eprintln!("CLI Error: {}", e);
            return std::process::ExitCode::from(65); // EX_DATAERR
        }
    };

    // Run application with validated config
    let result = run_application(validated_cli).await;

    // Map result to exit code
    result_to_exit_code(result)
}

async fn run_application(cli: adaptive_pipeline_bootstrap::ValidatedCli) -> Result<(), String> {
    // Application logic here
    Ok(())
}