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:

MatcherOperator
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.

MatcherSyntaxTag
Tagtagthe presence of a Tag on the event
PathpathPath (path field)
FileTypetypePath (file_type field, when Some)
FileEventKindkind or fekFileEventKind
Sourcesource or srcSource
Processprocess or pidProcess
SignalsignalSignal
ProcessCompletioncomplete or exitProcessCompletion
Prioritypriorityspecial: 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

Functions