mirror of
https://github.com/watchexec/watchexec.git
synced 2024-11-13 07:41:11 +01:00
This commit is contained in:
parent
8ad12b1f65
commit
7535e17661
1 changed files with 38 additions and 27 deletions
|
@ -236,11 +236,40 @@ pub fn make_config(args: &Args, state: &State) -> Result<Config> {
|
|||
);
|
||||
});
|
||||
|
||||
let show_events = || {
|
||||
if print_events {
|
||||
trace!("print events to stderr");
|
||||
for (n, event) in action.events.iter().enumerate() {
|
||||
eprintln!("[EVENT {n}] {event}");
|
||||
let show_events = {
|
||||
let events = action.events.clone();
|
||||
move || {
|
||||
if print_events {
|
||||
trace!("print events to stderr");
|
||||
for (n, event) in events.iter().enumerate() {
|
||||
eprintln!("[EVENT {n}] {event}");
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let clear_screen = {
|
||||
let events = action.events.clone();
|
||||
move || {
|
||||
if let Some(mode) = clear {
|
||||
match mode {
|
||||
ClearMode::Clear => {
|
||||
clearscreen::clear().ok();
|
||||
debug!("cleared screen");
|
||||
}
|
||||
ClearMode::Reset => {
|
||||
reset_screen();
|
||||
debug!("hard-reset screen");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// re-show events after clearing
|
||||
if print_events {
|
||||
trace!("print events to stderr");
|
||||
for (n, event) in events.iter().enumerate() {
|
||||
eprintln!("[EVENT {n}] {event}");
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -333,28 +362,6 @@ pub fn make_config(args: &Args, state: &State) -> Result<Config> {
|
|||
return action;
|
||||
}
|
||||
|
||||
// clear the screen before printing events
|
||||
if let Some(mode) = clear {
|
||||
match mode {
|
||||
ClearMode::Clear => {
|
||||
clearscreen::clear().ok();
|
||||
debug!("cleared screen");
|
||||
}
|
||||
ClearMode::Reset => {
|
||||
for cs in [
|
||||
ClearScreen::WindowsCooked,
|
||||
ClearScreen::WindowsVt,
|
||||
ClearScreen::VtLeaveAlt,
|
||||
ClearScreen::VtWellDone,
|
||||
ClearScreen::default(),
|
||||
] {
|
||||
cs.clear().ok();
|
||||
}
|
||||
debug!("hard-reset screen");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
show_events();
|
||||
|
||||
if let Some(delay) = delay_run {
|
||||
|
@ -388,6 +395,7 @@ pub fn make_config(args: &Args, state: &State) -> Result<Config> {
|
|||
OnBusyUpdate::Restart if cfg!(windows) => {
|
||||
job.restart();
|
||||
job.run(move |context| {
|
||||
clear_screen();
|
||||
setup_process(
|
||||
innerjob.clone(),
|
||||
context.command.clone(),
|
||||
|
@ -401,6 +409,7 @@ pub fn make_config(args: &Args, state: &State) -> Result<Config> {
|
|||
stop_timeout,
|
||||
);
|
||||
job.run(move |context| {
|
||||
clear_screen();
|
||||
setup_process(
|
||||
innerjob.clone(),
|
||||
context.command.clone(),
|
||||
|
@ -424,6 +433,7 @@ pub fn make_config(args: &Args, state: &State) -> Result<Config> {
|
|||
trace!("job finished, starting queued");
|
||||
job.start();
|
||||
job.run(move |context| {
|
||||
clear_screen();
|
||||
setup_process(
|
||||
innerjob.clone(),
|
||||
context.command.clone(),
|
||||
|
@ -442,6 +452,7 @@ pub fn make_config(args: &Args, state: &State) -> Result<Config> {
|
|||
trace!("job is not running, start it");
|
||||
job.start();
|
||||
job.run(move |context| {
|
||||
clear_screen();
|
||||
setup_process(
|
||||
innerjob.clone(),
|
||||
context.command.clone(),
|
||||
|
|
Loading…
Reference in a new issue