Fix cli for ProcessEnd

This commit is contained in:
Félix Saparelli 2021-10-22 05:48:37 +13:00
parent 470cdd698b
commit 963cd68cc4
1 changed files with 15 additions and 2 deletions

View File

@ -9,6 +9,7 @@ use watchexec::{
action::{Action, Outcome}, action::{Action, Outcome},
command::Shell, command::Shell,
config::{InitConfig, RuntimeConfig}, config::{InitConfig, RuntimeConfig},
event::ProcessEnd,
filter::tagged::TaggedFilterer, filter::tagged::TaggedFilterer,
fs::Watcher, fs::Watcher,
handler::PrintDisplay, handler::PrintDisplay,
@ -146,8 +147,20 @@ fn runtime(args: &ArgMatches<'static>) -> Result<(RuntimeConfig, Arc<TaggedFilte
let completion = action.events.iter().flat_map(|e| e.completions()).next(); let completion = action.events.iter().flat_map(|e| e.completions()).next();
if let Some(status) = completion { if let Some(status) = completion {
match status { match status {
Some(ex) if !ex.success() => { Some(ProcessEnd::ExitError(code)) => {
eprintln!("[Command exited with {}]", ex); eprintln!("[Command exited with {}]", code);
}
Some(ProcessEnd::ExitSignal(sig)) => {
eprintln!("[Command killed by {:?}]", sig);
}
Some(ProcessEnd::ExitStop(sig)) => {
eprintln!("[Command stopped by {:?}]", sig);
}
Some(ProcessEnd::Continued) => {
eprintln!("[Command continued]");
}
Some(ProcessEnd::Exception(ex)) => {
eprintln!("[Command ended by exception {:#x}]", ex);
} }
_ => {} _ => {}
} }