wip: Report harmony execution outcome
This commit is contained in:
32
harmony_cli/src/cli_reporter.rs
Normal file
32
harmony_cli/src/cli_reporter.rs
Normal file
@@ -0,0 +1,32 @@
|
||||
use std::sync::Mutex;
|
||||
|
||||
use harmony::instrumentation::{self, HarmonyEvent};
|
||||
use log::info;
|
||||
|
||||
pub fn init() {
|
||||
let details: Mutex<Vec<String>> = Mutex::new(vec![]);
|
||||
|
||||
instrumentation::subscribe("Harmony CLI Reporter", {
|
||||
move |event| {
|
||||
let mut details = details.lock().unwrap();
|
||||
|
||||
if let HarmonyEvent::InterpretExecutionFinished {
|
||||
execution_id: _,
|
||||
topology: _,
|
||||
interpret: _,
|
||||
score: _,
|
||||
outcome: Ok(outcome),
|
||||
} = event
|
||||
{
|
||||
if outcome.status == harmony::interpret::InterpretStatus::SUCCESS {
|
||||
details.extend(outcome.details.clone());
|
||||
}
|
||||
} else if let HarmonyEvent::HarmonyFinished = event {
|
||||
info!("Here's a summary of what happened:");
|
||||
for detail in details.iter() {
|
||||
println!("{detail}");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -8,6 +8,7 @@ use inquire::Confirm;
|
||||
use log::debug;
|
||||
|
||||
pub mod cli_logger; // FIXME: Don't make me pub
|
||||
mod cli_reporter;
|
||||
pub mod progress;
|
||||
pub mod theme;
|
||||
|
||||
@@ -116,6 +117,7 @@ pub async fn run_cli<T: Topology + Send + Sync + 'static>(
|
||||
args: Args,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
cli_logger::init();
|
||||
cli_reporter::init();
|
||||
|
||||
let mut maestro = Maestro::initialize(inventory, topology).await.unwrap();
|
||||
maestro.register_all(scores);
|
||||
|
||||
Reference in New Issue
Block a user