harn-cli 0.10.54

CLI for the Harn programming language — run, test, REPL, format, and lint
Documentation
//! User-facing `harn runs report` adapter.
//!
//! Harn VM owns report assembly; this module only adapts CLI paths and output.

use std::path::PathBuf;

use crate::cli::RunsReportArgs;

pub(crate) async fn run(args: RunsReportArgs) -> i32 {
    let path = crate::cli::resolve_run_path_or_exit(args.path.as_deref(), &args.source).await;
    let request = request_for_run_record(PathBuf::from(path), args.events_db);
    match harn_vm::orchestration::build_run_report(request).await {
        Ok(report) => match serde_json::to_string_pretty(&report) {
            Ok(rendered) => {
                println!("{rendered}");
                0
            }
            Err(error) => {
                eprintln!("error: failed to render run report: {error}");
                1
            }
        },
        Err(error) => {
            eprintln!("error: failed to build run report: {error}");
            1
        }
    }
}

pub(crate) fn request_for_run_record(
    path: PathBuf,
    events_db: Option<PathBuf>,
) -> harn_vm::orchestration::RunReportRequest {
    let source_root = path.parent().map(PathBuf::from);
    harn_vm::orchestration::RunReportRequest {
        run_record_path: path,
        events_db,
        source_root,
        ..harn_vm::orchestration::RunReportRequest::default()
    }
}