hen 0.20.2

Run protocol-aware API request collections from the command line or through MCP.
Documentation
use std::path::PathBuf;

use hen::{automation, error::HenResult};
use console::style;

use crate::cli::{CommandOutcome, ImportArgs};

pub(crate) fn import(args: ImportArgs) -> HenResult<CommandOutcome> {
    let result = automation::import_openapi(automation::ImportRequest {
        path: PathBuf::from(args.path),
        selector: args.selector,
        output: PathBuf::from(args.output),
    })?;

    println!("{}", style("Import complete").green().bold());
    println!("{} {}", style("Spec:").dim(), result.path.display());
    println!("{} {}", style("Output:").dim(), result.output.display());
    println!(
        "{} {} of {} operation(s)",
        style("Imported:").dim(),
        result.imported_operations.len(),
        result.plan.selected_operations.len()
    );

    if !result.warnings.is_empty() {
        println!("{}", style("Warnings").yellow().bold());
        for warning in &result.warnings {
            println!("  - {}", warning);
        }
    }

    Ok(CommandOutcome::success())
}