Polish up filterer crates for release (#331)

This commit is contained in:
Félix Saparelli 2022-06-22 23:48:46 +00:00
parent 4f808a1002
commit 6c3cb476a8
9 changed files with 40 additions and 8 deletions

View File

@ -77,7 +77,7 @@ pub fn runtime(args: &ArgMatches) -> Result<RuntimeConfig> {
let once = args.is_present("once");
let delay_run = args
.value_of("delay-run")
.map(|d| u64::from_str(d))
.map(u64::from_str)
.transpose()
.into_diagnostic()?
.map(Duration::from_secs);
@ -94,7 +94,7 @@ pub fn runtime(args: &ArgMatches) -> Result<RuntimeConfig> {
if once {
action.outcome(Outcome::both(
if let Some(delay) = &delay_run {
Outcome::both(Outcome::Sleep(delay.clone()), Outcome::Start)
Outcome::both(Outcome::Sleep(*delay), Outcome::Start)
} else {
Outcome::Start
},
@ -179,7 +179,7 @@ pub fn runtime(args: &ArgMatches) -> Result<RuntimeConfig> {
};
let start = if let Some(delay) = &delay_run {
Outcome::both(Outcome::Sleep(delay.clone()), start)
Outcome::both(Outcome::Sleep(*delay), start)
} else {
start
};

View File

@ -45,8 +45,8 @@ async fn main() -> Result<()> {
let mut builder = tracing_subscriber::fmt().with_env_filter(match verbosity {
0 => "watchexec-cli=warn",
1 => "watchexec=debug,watchexec-cli=debug",
2 => "watchexec=trace,watchexec-cli=trace",
1 => "watchexec=debug,watchexec-filterer-globset=debug,watchexec-filterer-ignore=debug,watchexec-filterer-tagged=debug,watchexec-cli=debug",
2 => "ignore-files=trace,project-origins=trace,watchexec=trace,watchexec-filterer-globset=trace,watchexec-filterer-ignore=trace,watchexec-filterer-tagged=trace,watchexec-cli=trace",
_ => "trace",
});

View File

@ -18,12 +18,15 @@ edition = "2021"
[dependencies]
ignore = "0.4.18"
tracing = "0.1.26"
watchexec = { version = "2.0.0", path = "../../lib" }
[dependencies.ignore-files]
version = "1.0.0"
path = "../../ignore-files"
[dependencies.watchexec]
version = "2.0.0"
path = "../../lib"
[dependencies.watchexec-filterer-ignore]
version = "1.0.0-almost-there"
path = "../ignore"

View File

@ -3,6 +3,11 @@
//! This filterer mimics the behavior of the `watchexec` v1 filter, but does not match it exactly,
//! due to differing internals. It is used as the default filterer in Watchexec CLI currently.
#![doc(html_favicon_url = "https://watchexec.github.io/logo:watchexec.svg")]
#![doc(html_logo_url = "https://watchexec.github.io/logo:watchexec.svg")]
#![warn(clippy::unwrap_used, missing_docs)]
#![deny(rust_2018_idioms)]
use std::{
ffi::OsString,
path::{Path, PathBuf},
@ -21,6 +26,7 @@ use watchexec_filterer_ignore::IgnoreFilterer;
/// A simple filterer in the style of the watchexec v1.17 filter.
#[derive(Debug)]
pub struct GlobsetFilterer {
#[cfg_attr(not(unix), allow(dead_code))]
origin: PathBuf,
filters: Gitignore,
ignores: Gitignore,

View File

@ -18,12 +18,15 @@ edition = "2021"
[dependencies]
ignore = "0.4.18"
tracing = "0.1.26"
watchexec = { version = "2.0.0", path = "../../lib" }
[dependencies.ignore-files]
version = "1.0.0"
path = "../../ignore-files"
[dependencies.watchexec]
version = "2.0.0"
path = "../../lib"
[dev-dependencies]
dunce = "1.0.2"
tracing-subscriber = "0.3.6"

View File

@ -13,5 +13,9 @@ _(Sub)filterer implementation for ignore files._
- Minimum Supported Rust Version: 1.58.0 (incurs a minor semver bump).
- Status: maintained.
This is mostly a thin layer above the [ignore-files](../../ignore-files) crate, and is meant to be
used as part of another more general filterer. However, there's nothing wrong with using it
directly if all that's needed is to handle ignore files.
[docs]: https://docs.rs/watchexec-filterer-ignore
[license]: ../../../LICENSE

View File

@ -2,6 +2,14 @@
//!
//! This filterer is meant to be used as a backing filterer inside a more complex or complete
//! filterer, and not as a standalone filterer.
//!
//! This is a fairly simple wrapper around the [`ignore_files`] crate, which is probably where you
//! want to look for any detail or to use this outside of Watchexec.
#![doc(html_favicon_url = "https://watchexec.github.io/logo:watchexec.svg")]
#![doc(html_logo_url = "https://watchexec.github.io/logo:watchexec.svg")]
#![warn(clippy::unwrap_used, missing_docs)]
#![deny(rust_2018_idioms)]
use ignore::Match;
use ignore_files::IgnoreFilter;

View File

@ -25,7 +25,6 @@ ignore = "0.4.18"
nom = "7.0.0"
regex = "1.5.4"
unicase = "2.6.0"
watchexec = { version = "2.0.0", path = "../../lib" }
[dependencies.ignore-files]
version = "1.0.0"
@ -37,6 +36,10 @@ features = [
"fs",
]
[dependencies.watchexec]
version = "2.0.0"
path = "../../lib"
[dependencies.watchexec-filterer-ignore]
version = "1.0.0-almost-there"
path = "../ignore"

View File

@ -71,6 +71,11 @@
//! writing, the ignore crate uses globset internally). Regex syntax is the default syntax of the
//! [regex] crate.
#![doc(html_favicon_url = "https://watchexec.github.io/logo:watchexec.svg")]
#![doc(html_logo_url = "https://watchexec.github.io/logo:watchexec.svg")]
#![warn(clippy::unwrap_used, missing_docs)]
#![deny(rust_2018_idioms)]
// to make filters
pub use regex::Regex;