Skip to content
This repository has been archived by the owner on Jan 18, 2025. It is now read-only.

Automatically find workspaces of all local dependencies and watch them. #216

Merged
merged 1 commit into from
Dec 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 62 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ name = "cargo-watch"

[dependencies]
camino = "1.0.4"
cargo_metadata = "0.15.1"
clap = "2.33.1"
log = "0.4.14"
shell-escape = "0.1.5"
Expand Down
52 changes: 21 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,49 +94,39 @@ FLAGS:
--no-gitignore Don’t use .gitignore files
--no-ignore Don’t use .ignore files
--no-restart Don’t restart command while it’s still running
-N, --notify Send a desktop notification when watchexec notices a change
(experimental, behaviour may change)
--poll Force use of polling for file changes
--postpone Postpone first run until a file changes
--skip-local-deps Don't try to find local dependencies of the current crate and watch
their working directories. Only watch the current directory.
-V, --version Display version information
--watch-when-idle Ignore events emitted while the commands run.
Will become default behaviour in 8.0.
--watch-when-idle Ignore events emitted while the commands run. Will become default
behaviour in 8.0.

OPTIONS:
-x, --exec <cmd>...
Cargo command(s) to execute on changes [default: check]

-x, --exec <cmd>... Cargo command(s) to execute on changes [default: check]
-s, --shell <cmd>... Shell command(s) to execute on changes

-d, --delay <delay>
File updates debounce delay in seconds [default: 0.5]

--features <features>
List of features passed to cargo invocations

-d, --delay <delay> File updates debounce delay in seconds [default: 0.5]
--features <features> List of features passed to cargo invocations
-i, --ignore <pattern>... Ignore a glob/gitignore-style pattern

-B <rust-backtrace>
Inject RUST_BACKTRACE=VALUE (generally you want to set it to 1)
into the environment

--use-shell <use-shell>
Use a different shell. E.g. --use-shell=bash. On Windows, try
--use-shell=powershell, which will become the default in 8.0.

-w, --watch <watch>...
Watch specific file(s) or folder(s) [default: .]

-C, --workdir <workdir>
Change working directory before running command [default: crate root]
-B <rust-backtrace> Inject RUST_BACKTRACE=VALUE (generally you want to set it to 1)
into the environment
--use-shell <use-shell> Use a different shell. E.g. --use-shell=bash
-w, --watch <watch>... Watch specific file(s) or folder(s). Disables finding and
watching local dependencies.
-C, --workdir <workdir> Change working directory before running command [default: crate
root]

ARGS:
<cmd:trail>... Full command to run. -x and -s will be ignored!

Cargo commands (-x) are always executed before shell commands (-s). You can use
the `-- command` style instead, note you'll need to use full commands, it won't
prefix `cargo` for you.
Cargo commands (-x) are always executed before shell commands (-s). You can use the `-- command`
style instead, note you'll need to use full commands, it won't prefix `cargo` for you.

By default, your entire project is watched, except for the target/ and .git/
folders, and your .ignore and .gitignore files are used to filter paths.
By default, the workspace directories of your project and all local dependencies are watched,
except for the target/ and .git/ folders. Your .ignore and .gitignore files are used to filter
paths.

On Windows, patterns given to -i have forward slashes (/) automatically
converted to backward ones (\) to ease command portability.
Expand Down
8 changes: 6 additions & 2 deletions cargo-watch.1
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,15 @@ Show paths that changed\.
Suppress output from cargo\-watch itself\.
.
.TP
\fB\-\-skip\-local\-deps\fR
Don't try to find local dependencies of the current crate and watch their working directories\. Only watch the current directory\.
.
.TP
\fB\-w\fR, \fB\-\-watch\fR \fIwatch\fR\.\.\.
Watch specific file(s) or folder(s)\.
Watch specific file(s) or folder(s)\. Disables finding and watching local dependencies\.
.
.P
By default, your entire project is watched, except for the target/ and \.git/ folders, and your \.ignore and \.gitignore files are used to filter paths\.
By default, the workspace directories of your project and all local dependencies are watched, except for the target/ and \.git/ folders\. Your \.ignore and \.gitignore files are used to filter paths\.
.
.TP
\fB\-i\fR, \fB\-\-ignore\fR \fIpattern\fR\.\.\.
Expand Down
7 changes: 5 additions & 2 deletions cargo-watch.1.ronn
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,13 @@ Show paths that changed.
* `-q`, `--quiet`:
Suppress output from cargo-watch itself.

* `--skip-local-deps`:
Don't try to find local dependencies of the current crate and watch their working directories. Only watch the current directory.

* `-w`, `--watch` <watch>...:
Watch specific file(s) or folder(s).
Watch specific file(s) or folder(s). Disables finding and watching local dependencies.

By default, your entire project is watched, except for the target/ and .git/ folders, and your .ignore and .gitignore files are used to filter paths.
By default, the workspace directories of your project and all local dependencies are watched, except for the target/ and .git/ folders. Your .ignore and .gitignore files are used to filter paths.

* `-i`, `--ignore` <pattern>...:
Ignore a glob/gitignore-style pattern.
Expand Down
10 changes: 7 additions & 3 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use clap::{App, AppSettings, Arg, ArgMatches, ErrorKind, SubCommand};
use std::{env, process};

pub fn parse() -> ArgMatches<'static> {
let footnote = "Cargo commands (-x) are always executed before shell commands (-s). You can use the `-- command` style instead, note you'll need to use full commands, it won't prefix `cargo` for you.\n\nBy default, your entire project is watched, except for the target/ and .git/ folders, and your .ignore and .gitignore files are used to filter paths.".to_owned();
let footnote = "Cargo commands (-x) are always executed before shell commands (-s). You can use the `-- command` style instead, note you'll need to use full commands, it won't prefix `cargo` for you.\n\nBy default, the workspace directories of your project and all local dependencies are watched, except for the target/ and .git/ folders. Your .ignore and .gitignore files are used to filter paths.".to_owned();

#[cfg(windows)] let footnote = format!("{}\n\nOn Windows, patterns given to -i have forward slashes (/) automatically converted to backward ones (\\) to ease command portability.", footnote);

Expand Down Expand Up @@ -166,8 +166,7 @@ pub fn parse() -> ArgMatches<'static> {
.empty_values(false)
.min_values(1)
.number_of_values(1)
.default_value(".")
.help("Watch specific file(s) or folder(s)"),
.help("Watch specific file(s) or folder(s). Disables finding and watching local dependencies."),
)
.arg(
Arg::with_name("use-shell")
Expand Down Expand Up @@ -204,6 +203,11 @@ pub fn parse() -> ArgMatches<'static> {
.raw(true)
.help("Full command to run. -x and -s will be ignored!"),
)
.arg(
Arg::with_name("skip-local-deps")
.help("Don't try to find local dependencies of the current crate and watch their working directories. Only watch the current directory.")
.long("skip-local-deps")
)
.after_help(footnote.as_str()),
);

Expand Down
Loading