Find: fast path walker¶
Effecient git-aware file finder with filtering capabilities.
Uses Linux commands: find, comm and git-ignore for an efficient path walker.
Example usage:
# Simple usage with default root
finder = cli2.Find(flags='-type f')
# Usage with filters and callback
def callback(filepath):
print(f"Found: {filepath}")
finder = cli2.Find(
root="/path/to/repo",
glob_include=['*.py'],
glob_exclude=['*test*'],
callback=callback
)
files = finder.run()
- class cli2.find.Find(root=None, glob_include=None, glob_exclude=None, callback=None, flags='')[source]¶
A class to walk through files and directories not ignored by git with optional filtering.
- root¶
Root directory for file operations
- glob_include¶
Optional list of glob patterns to include
- glob_exclude¶
Optional list of glob patterns to exclude
- callback¶
Optional callback function called for each file or directory
- flags¶
Set this to ‘-type f’ to limit find to files or example.