#[derive(Debug, Clone)]
pub struct TraversalOptions {
pub max_depth: Option<usize>,
pub follow_symlinks: bool,
pub include_hidden: bool,
pub gitignore: bool,
pub ignore_files: Vec<String>,
pub ignore_patterns: Vec<String>,
pub extensions: Vec<String>,
pub parallelism: usize,
}
impl Default for TraversalOptions {
fn default() -> Self {
Self {
max_depth: None,
follow_symlinks: false,
include_hidden: false,
gitignore: true,
ignore_files: vec![".ignore".into()],
ignore_patterns: vec![],
extensions: vec![],
parallelism: 4,
}
}
}
impl TraversalOptions {
pub fn with_gitignore(mut self, enabled: bool) -> Self {
self.gitignore = enabled;
self
}
pub fn with_ignore_files(mut self, files: &[&str]) -> Self {
self.ignore_files
.extend(files.iter().map(|s| s.to_string()));
self
}
pub fn with_patterns(mut self, patterns: &[&str]) -> Self {
self.ignore_patterns
.extend(patterns.iter().map(|s| s.to_string()));
self
}
pub fn with_extensions(mut self, exts: &[&str]) -> Self {
self.extensions.extend(exts.iter().map(|s| s.to_string()));
self
}
pub fn with_max_depth(mut self, depth: usize) -> Self {
self.max_depth = Some(depth);
self
}
pub fn include_hidden(mut self) -> Self {
self.include_hidden = true;
self
}
pub fn with_parallelism(mut self, n: usize) -> Self {
self.parallelism = n;
self
}
pub fn with_follow_symlinks(mut self, enabled: bool) -> Self {
self.follow_symlinks = enabled;
self
}
}