rg (ripgrep 15.2), grep (ours, on ripgrep's regex crates), find and xargs (ours), sed (uutils 0.3 wrapper), diff and cmp (uutils diffutils 0.6 with -r), fd 10.5, jaq 2.3, env and timeout. userland/spawn is a small Command-like client of the process interface. search-test.nu: 42 cases match native tools.
22 lines
834 B
Rust
22 lines
834 B
Rust
//! Run fd's visitor on the single-threaded ignore walker.
|
|
use ignore::{DirEntry, Error, Walk, WalkState};
|
|
pub struct WalkParallel(pub Walk);
|
|
impl WalkParallel {
|
|
pub fn run<'a>(self, factory: impl FnOnce() -> Box<dyn FnMut(Result<DirEntry, Error>) -> WalkState + 'a>) {
|
|
let mut visit = factory();
|
|
let mut skip: Option<std::path::PathBuf> = None;
|
|
for entry in self.0 {
|
|
if let Ok(e) = &entry {
|
|
if skip.as_ref().is_some_and(|p| e.path().starts_with(p)) { continue; }
|
|
skip = None;
|
|
}
|
|
let path = entry.as_ref().ok().map(|e| e.path().to_owned());
|
|
match visit(entry) {
|
|
WalkState::Quit => break,
|
|
WalkState::Skip => skip = path,
|
|
WalkState::Continue => (),
|
|
}
|
|
}
|
|
}
|
|
}
|