Crate watchexec_filterer_tagged
source ·Expand description
A filterer implementation that exposes the full capabilities of Watchexec.
Filters match against [event tags][Tag]; can be exact matches, glob matches, regex matches, or set matches; can reverse the match (equal/not equal, etc); and can be negated.
Filters can be generated from your application and inserted directly, or they can be parsed from a textual format:
[!]{Matcher}{Op}{Value}
For example:
path==/foo/bar
path*=**/bar
path~=bar$
!kind=file
There is a set of operators:
==
and!=
: exact match and exact not match (case insensitive)~=
and~!
: regex match and regex not match*=
and*!
: glob match and glob not match:=
and:!
: set match and set not match
Sets are a list of values separated by ,
.
In addition to the two-symbol operators, there is the =
“auto” operator, which maps to the
most convenient operator for the given matcher. The current mapping is:
Matcher | Operator |
---|---|
Tag | := (in set) |
Path | *= (glob) |
FileType | := (in set) |
FileEventKind | *= (glob) |
Source | := (in set) |
Process | := (in set) |
Signal | := (in set) |
ProcessCompletion | *= (glob) |
Priority | := (in set) |
Matchers correspond to Tags, but are not one-to-one: the path
matcher operates on
the path
part of the Path
tag, and the type
matcher operates on the file_type
, for
example.
Matcher | Syntax | Tag |
---|---|---|
Tag | tag | the presence of a Tag on the event |
Path | path | Path (path field) |
FileType | type | Path (file_type field, when Some) |
FileEventKind | kind or fek | FileEventKind |
Source | source or src | Source |
Process | process or pid | Process |
Signal | signal | Signal |
ProcessCompletion | complete or exit | ProcessCompletion |
Priority | priority | special: event [Priority ] |
Filters are checked in order, grouped per tag and per matcher. Filter groups may be checked in any order, but the filters in the groups are checked in add order. Path glob filters are always checked first, for internal reasons.
The negate
boolean field behaves specially: it is not operator negation, but rather the same
kind of behaviour that is applied to !
-prefixed globs in gitignore files: if a negated filter
matches the event, the result of the event checking for that matcher is reverted to true
, even
if a previous filter set it to false
. Unmatched negated filters are ignored.
Glob syntax is as supported by the ignore crate for Paths, and by globset otherwise. (As of writing, the ignore crate uses globset internally). Regex syntax is the default syntax of the regex crate.
Structs
- A tagged filter.
- A filter file.
- A compiled regular expression for searching Unicode haystacks.
- A complex filterer that can match any event tag and supports different matching operators.
Enums
- What a filter matches on.
- How a filter value is interpreted.
- A filter value (pattern to match with).
- Errors emitted by the
TaggedFilterer
.
Functions
- Finds all filter files that apply to the current runtime.