57 lines
1.8 KiB
Rust
57 lines
1.8 KiB
Rust
use std::sync::Mutex;
|
|
|
|
use harmony::{
|
|
instrumentation::{self, HarmonyEvent},
|
|
modules::application::ApplicationFeatureStatus,
|
|
};
|
|
|
|
use crate::theme;
|
|
|
|
pub fn init() {
|
|
let details: Mutex<Vec<String>> = Mutex::new(vec![]);
|
|
|
|
instrumentation::subscribe("Harmony CLI Reporter", {
|
|
move |event| {
|
|
let mut details = details.lock().unwrap();
|
|
|
|
match event {
|
|
HarmonyEvent::InterpretExecutionFinished {
|
|
execution_id: _,
|
|
topology: _,
|
|
interpret: _,
|
|
score: _,
|
|
outcome: Ok(outcome),
|
|
} => {
|
|
if outcome.status == harmony::interpret::InterpretStatus::SUCCESS {
|
|
details.extend(outcome.details.clone());
|
|
}
|
|
}
|
|
HarmonyEvent::ApplicationFeatureStateChanged {
|
|
topology: _,
|
|
application: _,
|
|
feature: _,
|
|
status:
|
|
ApplicationFeatureStatus::Installed {
|
|
details: feature_details,
|
|
},
|
|
} => {
|
|
details.extend(feature_details.clone());
|
|
}
|
|
HarmonyEvent::HarmonyFinished => {
|
|
if !details.is_empty() {
|
|
println!(
|
|
"\n{} All done! Here's what's next for you:",
|
|
theme::EMOJI_SUMMARY
|
|
);
|
|
for detail in details.iter() {
|
|
println!("- {detail}");
|
|
}
|
|
println!();
|
|
}
|
|
}
|
|
_ => {}
|
|
};
|
|
}
|
|
});
|
|
}
|