hen 0.20.0

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

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

use crate::{
    cli::{CommandOutcome, InspectArgs},
    cli_output::{
        print_inspection_report, print_inspection_result,
        print_machine_error_for_inspect,
    },
};

pub(crate) fn inspect(args: InspectArgs) -> HenResult<CommandOutcome> {
    if args.output.is_text() {
        let result = automation::inspect_path(PathBuf::from(args.path))?;
        print_inspection_result(&result);
        return Ok(CommandOutcome::success());
    }

    let output = args.output;
    let suite_name = args.path.clone();

    match automation::inspect_path(PathBuf::from(args.path)) {
        Ok(result) => {
            print_inspection_report(output, &result);
            Ok(CommandOutcome::success())
        }
        Err(err) => {
            print_machine_error_for_inspect(output, &suite_name, &err);
            Ok(CommandOutcome::with_exit_code(err.exit_code()))
        }
    }
}