iskra 0.4.0

A safe, modern, Rust-native data transfer tool.
Documentation
use iskra::cli::run_cli;
use iskra::cli_args::parse_iskra_cli_args;

/// Entry point for the Iskra application.
// This function initialises the asynchronous runtime and executes the CLI.
#[tokio::main]
async fn main() {
    // Run the CLI and handle any errors gracefully.
    // Parse CLI args first to check for --verbose-errors
    let orig_args: Vec<_> = std::env::args_os().collect();
    let cli = match parse_iskra_cli_args(orig_args) {
        Ok(cli) => cli,
        Err(e) => {
            eprintln!("\x1b[1;31mIskra CLI parse error:\x1b[0m {e}");
            let code = match &e {
                iskra::IskraError::Config { .. } => 10,      // CLI/config/parse error
                iskra::IskraError::Http { .. } => 20,        // HTTP client/network error
                iskra::IskraError::Timeout { .. } => 20,     // Timeout error
                iskra::IskraError::Status { .. } => 30,      // HTTP status error
                iskra::IskraError::Io { .. } => 40,          // File I/O error
                iskra::IskraError::Cache { .. } => 40,       // Cache error
                _ => 50,                                     // Other/unknown/internal error
            };
            std::process::exit(code);
        }
    };
    let verbose_flag = cli.verbose_errors;
    match run_cli().await {
        Ok(_) => {}
        Err(e) => {
            let verbose_env = std::env::var_os("ISKRA_ERROR_VERBOSE").is_some();
            if verbose_flag || verbose_env {
                e.print_report();
            } else {
                eprintln!("\x1b[1;31mIskra Error:\x1b[0m {e}");
            }
            // Use Iskra exit codes for error classes
            let code = match &e {
                iskra::IskraError::Config { .. } => 10,      // CLI/config/parse error
                iskra::IskraError::Http { .. } => 20,        // HTTP client/network error
                iskra::IskraError::Timeout { .. } => 20,     // Timeout error
                iskra::IskraError::Status { .. } => 30,      // HTTP status error
                iskra::IskraError::Io { .. } => 40,          // File I/O error
                iskra::IskraError::Cache { .. } => 40,       // Cache error
                _ => 50,                                     // Other/unknown/internal error
            };
            std::process::exit(code);
        }
    }
}