diff --git a/Cargo.toml b/Cargo.toml index 08ea434..928d2c6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,3 +8,4 @@ anyhow = "1.0" regex = "1.10" ureq = "2.10" kxio = "1.2" +ignore = "0.4" diff --git a/src/main.rs b/src/main.rs index 02eb5e9..9fef957 100644 --- a/src/main.rs +++ b/src/main.rs @@ -25,12 +25,19 @@ fn main() -> Result<()> { println!("Prefix: {}", config.prefix_pattern); println!("Issues: {}", config.issue_pattern); - // TODO: scan files in workdir - // TODO: ignore files listed in .rgignore .ignore or .gitignore - let mut found_markers = FoundMarkers::default(); - scan_files(&config, &mut found_markers)?; + for file in ignore::WalkBuilder::new(config.fs.base()) + .hidden(false) + .build() + .flatten() + { + let path = file.path(); + if path.ends_with("/") { + continue; + } + scan_file(path, &config, &mut found_markers)?; + } println!("{found_markers:?}"); @@ -82,23 +89,6 @@ impl FoundMarkers { } } -fn scan_files(config: &Config, found_markers: &mut FoundMarkers) -> Result<()> { - scan_dir(config.fs.base(), config, found_markers) -} - -fn scan_dir(dir: &Path, config: &Config, found_markers: &mut FoundMarkers) -> Result<()> { - println!("dir : {}", dir.to_string_lossy()); - let read_dir = config.fs.dir_read(dir)?; - for entry in read_dir { - match entry? { - DirItem::File(file) => scan_file(&file, config, found_markers), - DirItem::Dir(dir) => scan_dir(&dir, config, found_markers), - DirItem::SymLink(_) | DirItem::Fifo(_) | DirItem::Unsupported(_) => Ok(()), - }?; - } - Ok(()) -} - fn scan_file(file: &Path, config: &Config, found_markers: &mut FoundMarkers) -> Result<()> { println!("file: {}", file.to_string_lossy()); config