Introducing Wax: portable and opinionated globs.
Registry: https://crates.io/crates/wax
Repository: https://github.com/olson-sean-k/wax
API Documentation: https://docs.rs/wax/latest/wax/
I've recently been working on a crate that provides glob patterns for nominally matching paths and directory trees. I'm aware of glob, globset, globwalk, and capturing-glob, but each lacked features that I felt were important. I think Wax is in a fairly usable state with the 0.5.0 release and I thought I'd share it here. Some of its features:
- Familiar and expressive syntax with rules that avoid nonsense, inconsistent, and ambiguous patterns.
- Emphasis on component boundaries and the structure of paths and the file system.
- Both logical path matching and semantic directory tree matching.
- A flexible walk API that allows arbitrary filtering with control of the file system traversal (i.e., trees can be discarded).
- Multiple patterns can be logically matched efficiently and simultaneously using combinators.
- Optional integration with miette for errors that provide compiler-like and human-readable diagnostics.
- Metadata APIs that describe glob expressions, such as the index and sub-expression location of capturing tokens.
- No unnecessary reads when matching a directory tree. For example, negation patterns that terminate in a pattern with unbounded depth and variance do not read matching trees, meaning patterns like
secret/**will not read the tree beneathsecret, etc.
Under the hood, Wax is essentially a transpiler: it parses glob expressions and ultimately compiles them into regular expressions. The token tree is used for analysis, diagnostics, and to make decisions about matching and reads. Maybe this can be useful to some folks. Please take a look. Thanks!