README.md
1ignore
2======
3The ignore crate provides a fast recursive directory iterator that respects
4various filters such as globs, file types and `.gitignore` files. This crate
5also provides lower level direct access to gitignore and file type matchers.
6
7[![Build status](https://github.com/BurntSushi/ripgrep/workflows/ci/badge.svg)](https://github.com/BurntSushi/ripgrep/actions)
8[![](https://img.shields.io/crates/v/ignore.svg)](https://crates.io/crates/ignore)
9
10Dual-licensed under MIT or the [UNLICENSE](https://unlicense.org/).
11
12### Documentation
13
14[https://docs.rs/ignore](https://docs.rs/ignore)
15
16### Usage
17
18Add this to your `Cargo.toml`:
19
20```toml
21[dependencies]
22ignore = "0.4"
23```
24
25### Example
26
27This example shows the most basic usage of this crate. This code will
28recursively traverse the current directory while automatically filtering out
29files and directories according to ignore globs found in files like
30`.ignore` and `.gitignore`:
31
32
33```rust,no_run
34use ignore::Walk;
35
36for result in Walk::new("./") {
37 // Each item yielded by the iterator is either a directory entry or an
38 // error, so either print the path or the error.
39 match result {
40 Ok(entry) => println!("{}", entry.path().display()),
41 Err(err) => println!("ERROR: {}", err),
42 }
43}
44```
45
46### Example: advanced
47
48By default, the recursive directory iterator will ignore hidden files and
49directories. This can be disabled by building the iterator with `WalkBuilder`:
50
51```rust,no_run
52use ignore::WalkBuilder;
53
54for result in WalkBuilder::new("./").hidden(false).build() {
55 println!("{:?}", result);
56}
57```
58
59See the documentation for `WalkBuilder` for many other options.
60