From 1fd5c85317ae1eaa561c573cc05085673a7946e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Saparelli?= Date: Tue, 24 Aug 2021 23:20:21 +1200 Subject: [PATCH] Good idea but let's keep compat for now --- cli/src/config.rs | 33 +++++++++------------------------ cli/src/main.rs | 9 ++++----- 2 files changed, 13 insertions(+), 29 deletions(-) diff --git a/cli/src/config.rs b/cli/src/config.rs index c75b6a3..840ef9c 100644 --- a/cli/src/config.rs +++ b/cli/src/config.rs @@ -4,14 +4,7 @@ use std::{ use clap::ArgMatches; use color_eyre::eyre::{eyre, Result}; -use watchexec::{ - action::{Action, Outcome, Signal}, - command::Shell, - config::{InitConfig, RuntimeConfig}, - fs::Watcher, - handler::PrintDisplay, - signal::Signal as InputSignal, -}; +use watchexec::{action::{Action, Outcome, Signal}, command::Shell, config::{InitConfig, RuntimeConfig}, event::Event, fs::Watcher, handler::PrintDisplay, signal::Signal as InputSignal}; pub fn new(args: &ArgMatches<'static>) -> Result<(InitConfig, RuntimeConfig)> { Ok((init(args)?, runtime(args)?)) @@ -94,13 +87,17 @@ fn runtime(args: &ArgMatches<'static>) -> Result { let fut = async { Ok::<(), Infallible>(()) }; if print_events { - for event in &action.events { + for (n, event) in action.events.iter().enumerate() { for path in event.paths() { - eprintln!("[EVENT] Path: {}", path.display()); + eprintln!("[EVENT {}] Path: {} -- {:?}", n, path.display(), event.metadata); } for signal in event.signals() { - eprintln!("[EVENT] Signal: {:?}", signal); + eprintln!("[EVENT {}] Signal: {:?} -- {:?}", n, signal, event.metadata); + } + + if event == &Event::default() { + eprintln!("[EVENT {}] Empty -- {:?}", n, event.metadata); } } } @@ -125,19 +122,7 @@ fn runtime(args: &ArgMatches<'static>) -> Result { } if signals.contains(&InputSignal::Interrupt) { - let out = if signals - .iter() - .filter(|s| **s == InputSignal::Interrupt) - .count() >= 2 - { - Outcome::both(Outcome::Stop, Outcome::Exit) - } else if cfg!(windows) { - Outcome::if_running(Outcome::Stop, Outcome::Exit) - } else { - Outcome::if_running(Outcome::Signal(Signal::SIGINT), Outcome::Exit) - }; - - action.outcome(out); + action.outcome(Outcome::both(Outcome::Stop, Outcome::Exit)); return fut; } diff --git a/cli/src/main.rs b/cli/src/main.rs index e54e65b..e62ad10 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -1,7 +1,6 @@ use std::env::var; use color_eyre::eyre::Result; -use tracing_subscriber::filter::LevelFilter; use watchexec::{event::Event, Watchexec}; mod args; @@ -19,11 +18,11 @@ async fn main() -> Result<()> { if args.is_present("verbose") { tracing_subscriber::fmt() - .with_max_level(match args.occurrences_of("verbose") { + .with_env_filter(match args.occurrences_of("verbose") { 0 => unreachable!(), - 1 => LevelFilter::INFO, - 2 => LevelFilter::DEBUG, - _ => LevelFilter::TRACE, + 1 => "watchexec=debug", + 2 => "watchexec=trace", + _ => "trace", }) .try_init() .ok();