From 29e7780fdcf2287082388a144cac87e36a17bef5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Saparelli?= Date: Fri, 3 Sep 2021 05:43:53 +1200 Subject: [PATCH] Add process completion handling to cli demo --- cli/src/config.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/cli/src/config.rs b/cli/src/config.rs index 8941f04..8804e17 100644 --- a/cli/src/config.rs +++ b/cli/src/config.rs @@ -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 { 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); }