mirror of https://github.com/passcod/cargo-watch
Make “watch when idle” the default, instead of restarting
This commit is contained in:
parent
60b221fe9e
commit
68221f05cd
|
@ -8,8 +8,6 @@ const OPTSET_OUTPUT: &str = "OUTPUT";
|
|||
const OPTSET_BEHAVIOUR: &str = "BEHAVIOUR";
|
||||
const OPTSET_WORKSPACES: &str = "WORKSPACES";
|
||||
|
||||
// --watch-when-idle is now default
|
||||
|
||||
#[derive(Debug, Clone, clap::Parser)]
|
||||
#[clap(name = "cargo-watch", about, version)]
|
||||
pub struct Args {
|
||||
|
@ -72,12 +70,15 @@ pub struct Args {
|
|||
)]
|
||||
pub no_dot_ignores: bool,
|
||||
|
||||
/// Don’t restart command while it’s still running
|
||||
/// Restart the command set when events come in while it’s still running
|
||||
///
|
||||
/// Note that this can lead to loops when the command set causes a watched file to change. In
|
||||
/// that case, you should restrict what is watched with --watch and/or --ignore.
|
||||
#[clap(
|
||||
long,
|
||||
help_heading = OPTSET_BEHAVIOUR,
|
||||
)]
|
||||
pub no_restart: bool,
|
||||
pub restart: bool,
|
||||
|
||||
/// Reserved for workspace support
|
||||
#[clap(
|
||||
|
|
|
@ -132,10 +132,10 @@ pub fn runtime(args: &Args, command_order: Vec<&'static str>) -> Result<RuntimeC
|
|||
let quiet = args.quiet;
|
||||
let clear = args.clear;
|
||||
let notif = args.notif;
|
||||
let on_busy = if args.no_restart {
|
||||
"do-nothing"
|
||||
} else {
|
||||
let on_busy = if args.restart {
|
||||
"restart"
|
||||
} else {
|
||||
"do-nothing"
|
||||
};
|
||||
|
||||
// TODO: add using SubSignal in Args directly
|
||||
|
@ -262,7 +262,6 @@ pub fn runtime(args: &Args, command_order: Vec<&'static str>) -> Result<RuntimeC
|
|||
"do-nothing" => Outcome::DoNothing,
|
||||
"restart" => Outcome::both(Outcome::Stop, start),
|
||||
// "signal" => Outcome::Signal(signal),
|
||||
// "queue" => Outcome::wait(start),
|
||||
_ => Outcome::DoNothing,
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
This first one tests that test-cw behaves correctly:
|
||||
This first one tests that test-cw behaves correctly on a single run:
|
||||
|
||||
```
|
||||
$ test-cw --
|
||||
|
@ -13,15 +13,16 @@ out
|
|||
```
|
||||
|
||||
|
||||
This one uses `--quit-after-n`. As the default is to restart the command on
|
||||
event, we're looking for the second command to start in the middle of the
|
||||
first. We ignore the output after the second start because the order of the
|
||||
`ForceStop` message and the `in` message can vary. But we're looking for the
|
||||
`quit-after-n` signalling message afterwards to check that Cargo Watch stopped.
|
||||
This one uses `--quit-after-n`. With `--restart`, we restart the command on
|
||||
event without waiting for it to stop, so we're looking for the second command
|
||||
to start in the middle of the first. We ignore the output after the second
|
||||
start because the order of the `ForceStop` message and the `in` message can
|
||||
vary. But we're looking for the `quit-after-n` signalling message afterwards to
|
||||
check that Cargo Watch stopped.
|
||||
|
||||
```
|
||||
$ test-cw --touch File --touch Other --between 500 --
|
||||
> --quit-after-n 2 --postpone -S sh -s 'echo in; sleep 1; echo out'
|
||||
> --restart --quit-after-n 2 --postpone -S sh -s 'echo in; sleep 1; echo out'
|
||||
? 0
|
||||
[[Running `echo in; sleep 1; echo out`]]
|
||||
in
|
||||
|
@ -39,7 +40,7 @@ signalling from the tester.
|
|||
|
||||
```
|
||||
$ test-cw --touch File --touch Other --between 500 --expect-timeout --
|
||||
> --postpone -S sh -s 'echo in; sleep 1; echo out'
|
||||
> --restart --postpone -S sh -s 'echo in; sleep 1; echo out'
|
||||
? 0
|
||||
[[Running `echo in; sleep 1; echo out`]]
|
||||
in
|
||||
|
|
Loading…
Reference in New Issue