Add process completion handling to cli demo

This commit is contained in:
Félix Saparelli 2021-09-03 05:43:53 +12:00
parent ec6b508894
commit 29e7780fdc
No known key found for this signature in database
GPG Key ID: B948C4BAE44FC474
1 changed files with 13 additions and 1 deletions

View File

@ -8,7 +8,7 @@ use watchexec::{
action::{Action, Outcome, Signal},
command::Shell,
config::{InitConfig, RuntimeConfig},
event::Event,
event::{Event, Particle},
fs::Watcher,
handler::PrintDisplay,
signal::Signal as InputSignal,
@ -109,6 +109,18 @@ fn runtime(args: &ArgMatches<'static>) -> Result<RuntimeConfig> {
eprintln!("[EVENT {}] Signal: {:?} -- {:?}", n, signal, event.metadata);
}
for com in event
.particulars
.iter()
.filter(|p| matches!(p, Particle::ProcessCompletion(_)))
{
if let Particle::ProcessCompletion(Some(status)) = com {
eprintln!("[EVENT {}] Process Finished with {}", n, status);
} else {
eprintln!("[EVENT {}] Process Finished", n);
}
}
if event == &Event::default() {
eprintln!("[EVENT {}] Empty -- {:?}", n, event.metadata);
}