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

Commit

Permalink
Merge pull request #89 from passcod/translate-ignore-on-windows
Browse files Browse the repository at this point in the history
Translate commandline ignores on Windows
  • Loading branch information
passcod authored Jul 13, 2018
2 parents 747502b + 3c280ea commit 09041c5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ and .git/ folders, and your .gitignore files are used to filter paths.
See the [`glob::Pattern` docs][glob::Pattern] for a more detailed
specification of the glob matching syntax used for `--ignore`.

On Windows, patterns should be specified with Windows-style (`\\`) separators.
Unix-style separators (`/`) would not match Windows paths, which could be
confusing and give the appearance of commandline ignores not working.

From Cargo Watch 7.0.0, `/` in commandline ignores are automatically translated
to `\\` when running on Windows, but one should still try to write the correct
patterns for the platform, as there may be more subtle differences.

[glob::Pattern]: https://doc.rust-lang.org/glob/glob/struct.Pattern.html

### Reloading servers
Expand Down Expand Up @@ -238,8 +246,8 @@ this tool depends on, or the [issues for the Watchexec tool][watchexec-issues]
that we use under the covers.

If you want more verbose output, try running with the `--debug` flag. Note that
this will also enable debug mode for watchexec. When filing an issue, make sure
to include a log with `--debug` enabled so problems can be diagnosed better.
this will also enable debug mode for watchexec. When filing an issue, **make
sure to include a log with `--debug` enabled so problems can be diagnosed.**

[notify-issues]: https://github.com/passcod/notify/issues
[watch-issues]: https://github.com/passcod/cargo-watch/issues
Expand Down
6 changes: 5 additions & 1 deletion src/args.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
use clap::{App, AppSettings, Arg, ArgMatches, SubCommand};

pub fn parse() -> ArgMatches<'static> {
let footnote = "Cargo commands (-x) are always executed before shell commands (-s).\n\nBy default, your entire project is watched, except for the target/ and .git/ folders, and your .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);

let matches = App::new(env!("CARGO_PKG_NAME"))
.bin_name("cargo")
.version(env!("CARGO_PKG_VERSION"))
Expand Down Expand Up @@ -127,7 +131,7 @@ pub fn parse() -> ArgMatches<'static> {
.default_value(".")
.help("Watch specific file(s) or folder(s)"))

.after_help("Cargo commands (-x) are always executed before shell commands (-s).\n\nBy default, your entire project is watched, except for the target/ and .git/ folders, and your .gitignore files are used to filter paths.")
.after_help(footnote.as_str())

).get_matches();

Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ fn get_ignores(debug: bool, matches: &ArgMatches) -> (bool, Vec<String>) {

if matches.is_present("ignore") {
for ignore in values_t!(matches, "ignore", String).unwrap_or_else(|e| e.exit()) {
#[cfg(windows)] let ignore = ignore.replace("/", MAIN_SEPARATOR);
opts.push(ignore);
}
}
Expand Down

0 comments on commit 09041c5

Please sign in to comment.