Good idea but let's keep compat for now
This commit is contained in:
parent
6df6d6fd5a
commit
1fd5c85317
|
@ -4,14 +4,7 @@ use std::{
|
||||||
|
|
||||||
use clap::ArgMatches;
|
use clap::ArgMatches;
|
||||||
use color_eyre::eyre::{eyre, Result};
|
use color_eyre::eyre::{eyre, Result};
|
||||||
use watchexec::{
|
use watchexec::{action::{Action, Outcome, Signal}, command::Shell, config::{InitConfig, RuntimeConfig}, event::Event, fs::Watcher, handler::PrintDisplay, signal::Signal as InputSignal};
|
||||||
action::{Action, Outcome, Signal},
|
|
||||||
command::Shell,
|
|
||||||
config::{InitConfig, RuntimeConfig},
|
|
||||||
fs::Watcher,
|
|
||||||
handler::PrintDisplay,
|
|
||||||
signal::Signal as InputSignal,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub fn new(args: &ArgMatches<'static>) -> Result<(InitConfig, RuntimeConfig)> {
|
pub fn new(args: &ArgMatches<'static>) -> Result<(InitConfig, RuntimeConfig)> {
|
||||||
Ok((init(args)?, runtime(args)?))
|
Ok((init(args)?, runtime(args)?))
|
||||||
|
@ -94,13 +87,17 @@ fn runtime(args: &ArgMatches<'static>) -> Result<RuntimeConfig> {
|
||||||
let fut = async { Ok::<(), Infallible>(()) };
|
let fut = async { Ok::<(), Infallible>(()) };
|
||||||
|
|
||||||
if print_events {
|
if print_events {
|
||||||
for event in &action.events {
|
for (n, event) in action.events.iter().enumerate() {
|
||||||
for path in event.paths() {
|
for path in event.paths() {
|
||||||
eprintln!("[EVENT] Path: {}", path.display());
|
eprintln!("[EVENT {}] Path: {} -- {:?}", n, path.display(), event.metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
for signal in event.signals() {
|
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<RuntimeConfig> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if signals.contains(&InputSignal::Interrupt) {
|
if signals.contains(&InputSignal::Interrupt) {
|
||||||
let out = if signals
|
action.outcome(Outcome::both(Outcome::Stop, Outcome::Exit));
|
||||||
.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);
|
|
||||||
return fut;
|
return fut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use std::env::var;
|
use std::env::var;
|
||||||
|
|
||||||
use color_eyre::eyre::Result;
|
use color_eyre::eyre::Result;
|
||||||
use tracing_subscriber::filter::LevelFilter;
|
|
||||||
use watchexec::{event::Event, Watchexec};
|
use watchexec::{event::Event, Watchexec};
|
||||||
|
|
||||||
mod args;
|
mod args;
|
||||||
|
@ -19,11 +18,11 @@ async fn main() -> Result<()> {
|
||||||
|
|
||||||
if args.is_present("verbose") {
|
if args.is_present("verbose") {
|
||||||
tracing_subscriber::fmt()
|
tracing_subscriber::fmt()
|
||||||
.with_max_level(match args.occurrences_of("verbose") {
|
.with_env_filter(match args.occurrences_of("verbose") {
|
||||||
0 => unreachable!(),
|
0 => unreachable!(),
|
||||||
1 => LevelFilter::INFO,
|
1 => "watchexec=debug",
|
||||||
2 => LevelFilter::DEBUG,
|
2 => "watchexec=trace",
|
||||||
_ => LevelFilter::TRACE,
|
_ => "trace",
|
||||||
})
|
})
|
||||||
.try_init()
|
.try_init()
|
||||||
.ok();
|
.ok();
|
||||||
|
|
Loading…
Reference in New Issue