Created
January 9, 2023 22:41
-
-
Save wulfgarpro/f747b8ca562a29b5b754e721188cb3e8 to your computer and use it in GitHub Desktop.
Build a matcher for a set of glob overrides using the `ignore` crate.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use ignore::WalkBuilder; | |
use ignore::overrides::OverrideBuilder; | |
fn main() { | |
let folder = "/tmp/files"; | |
let mut override_builder = OverrideBuilder::new(folder); | |
override_builder.add("!test.txt").unwrap(); | |
override_builder.add("!test.rs").unwrap(); | |
let or = override_builder.build().unwrap(); | |
let mut builder = WalkBuilder::new(folder); | |
builder.overrides(or); | |
builder.standard_filters(false); | |
for result in builder.build() { | |
let dent = result.unwrap(); | |
println!("{}", dent.path().display()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment