#glob #ignore #gitignore #pattern #file

tree_sitter_grep_ignore

(A forked version of ignore used internally by tree-sitter-grep) A fast library for efficiently matching ignore files such as .gitignore against file paths

1 unstable release

0.4.20-dev.0 Jul 12, 2023

#896 in Filesystem

Download history 14/week @ 2023-10-18 13/week @ 2023-10-25 15/week @ 2023-11-01 12/week @ 2023-11-08 18/week @ 2023-11-15 18/week @ 2023-11-22 9/week @ 2023-11-29 9/week @ 2023-12-06 14/week @ 2023-12-13 14/week @ 2023-12-20 10/week @ 2023-12-27 10/week @ 2024-01-03 13/week @ 2024-01-10 63/week @ 2024-01-17 10/week @ 2024-01-24 8/week @ 2024-01-31

96 downloads per month
Used in 3 crates (2 directly)

Unlicense OR MIT

325KB
6.5K SLoC

ignore

The ignore crate provides a fast recursive directory iterator that respects various filters such as globs, file types and .gitignore files. This crate also provides lower level direct access to gitignore and file type matchers.

Build status

Dual-licensed under MIT or the UNLICENSE.

Documentation

https://docs.rs/ignore

Usage

Add this to your Cargo.toml:

[dependencies]
ignore = "0.4"

Example

This example shows the most basic usage of this crate. This code will recursively traverse the current directory while automatically filtering out files and directories according to ignore globs found in files like .ignore and .gitignore:

use ignore::Walk;

for result in Walk::new("./") {
    // Each item yielded by the iterator is either a directory entry or an
    // error, so either print the path or the error.
    match result {
        Ok(entry) => println!("{}", entry.path().display()),
        Err(err) => println!("ERROR: {}", err),
    }
}

Example: advanced

By default, the recursive directory iterator will ignore hidden files and directories. This can be disabled by building the iterator with WalkBuilder:

use ignore::WalkBuilder;

for result in WalkBuilder::new("./").hidden(false).build() {
    println!("{:?}", result);
}

See the documentation for WalkBuilder for many other options.

Dependencies

~4.5–6MB
~109K SLoC