pub struct Find<'a> { /* private fields */ }Expand description
File finder with pattern matching support.
Create via Find::new() and chain methods to configure the search.
§Examples
§Basic Pattern Matching
use heroforge_core::Repository;
use heroforge_core::fs::Find;
let repo = Repository::open("project.forge")?;
// Find all Rust source files
let rust_files = Find::new(&repo)
.pattern("**/*.rs")
.paths()?;
// Find multiple patterns
let source_files = Find::new(&repo)
.patterns(&["**/*.rs", "**/*.toml", "**/*.md"])
.paths()?;§Ignore Patterns
// Exclude build artifacts
let files = Find::new(&repo)
.pattern("**/*.rs")
.ignore("target/**")
.ignore("**/generated/**")
.paths()?;
// Use common gitignore patterns
let clean = Find::new(&repo)
.pattern("**/*")
.use_gitignore()
.ignore_hidden()
.paths()?;§Directory and Depth Limits
// Search only in src directory
let src_files = Find::new(&repo)
.in_dir("src")
.pattern("**/*.rs")
.paths()?;
// Limit depth to 2 levels
let shallow = Find::new(&repo)
.pattern("**/*")
.max_depth(2)
.paths()?;Implementations§
Source§impl<'a> Find<'a>
impl<'a> Find<'a>
Sourcepub fn new(repo: &'a Repository) -> Self
pub fn new(repo: &'a Repository) -> Self
Create a new Find instance for the given repository.
Sourcepub fn pattern(self, pattern: &str) -> Self
pub fn pattern(self, pattern: &str) -> Self
Add a glob pattern to match files.
Supports standard glob syntax:
*matches any sequence of characters in a path segment**matches any sequence of path segments?matches any single character[abc]matches any character in the brackets
Sourcepub fn ignore_patterns(self, patterns: &[&str]) -> Self
pub fn ignore_patterns(self, patterns: &[&str]) -> Self
Add multiple ignore patterns at once.
Exclude hidden files (files starting with .).
Sourcepub fn use_gitignore(self) -> Self
pub fn use_gitignore(self) -> Self
Apply common gitignore-style patterns.
Sourcepub fn ignore_case(self) -> Self
pub fn ignore_case(self) -> Self
Enable case-insensitive pattern matching.
Sourcepub fn files_only(self) -> Self
pub fn files_only(self) -> Self
Only match regular files (exclude executables and symlinks).
Sourcepub fn executables_only(self) -> Self
pub fn executables_only(self) -> Self
Only match executable files.
Sourcepub fn symlinks_only(self) -> Self
pub fn symlinks_only(self) -> Self
Only match symbolic links.
Sourcepub fn execute(&self) -> Result<FindResult>
pub fn execute(&self) -> Result<FindResult>
Execute the search and return full results with metadata.