Add Inclusion/Exclusion File Filtering via Glob Patterns#9
Merged
simone-viozzi merged 5 commits intomainfrom Feb 16, 2025
Merged
Add Inclusion/Exclusion File Filtering via Glob Patterns#9simone-viozzi merged 5 commits intomainfrom
simone-viozzi merged 5 commits intomainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces two new, repeatable CLI options to allow users to filter files by inclusion and exclusion patterns. The options accept glob-style patterns (with optional brace expansion) so that users can intuitively select which files should be processed without having to provide full, exact paths. This feature provides more granular control over file selection and helps avoid redundant specification of similar paths.
Proposed Changes
New CLI Options:
--include(-i):--exclude(-e):Pattern Matching:
pathspeclibrary) to support both wildcards (e.g.,"src/*.py") and brace expansion (e.g.,"src/{module1,module2}.py").Processing Order:
User Feedback (Optional):
Rationale
Intuitive Syntax:
Glob patterns (e.g.,
"src/*.py") are widely recognized and understood by developers. This avoids the need for users to specify lengthy or exact file paths.Flexibility:
The ability to combine multiple patterns lets users select broad classes of files (e.g., all Python files) and then exclude specific ones (e.g.,
src/__init__.py), all in one command.Consistency:
The new options align with the
.gitignoresyntax already in use, so users familiar with that system will quickly understand how to use the new parameters.Implementation Ease:
Leveraging existing libraries (like
pathspecor Python’sfnmatch) minimizes the development effort while providing robust pattern matching.Examples
Include all Python files in the
srcdirectory:python gpt-copy /project/root --include "src/*.py"Include multiple specific modules (using brace expansion):
python gpt-copy /project/root --include "src/{module1,module2}.py"Include all
.pyfiles but exclude initialization files:Exclude test files across the project:
python gpt-copy /project/root --exclude "src/tests/*"Acceptance Criteria
CLI Interface:
--include(alias-i) and--exclude(alias-e) as repeatable options.File Selection:
--includeis used, only files matching at least one include pattern are processed.--excludeis used, any file matching an exclude pattern is omitted—even if it would otherwise be included.Pattern Matching:
*,?) and brace expansion (e.g.,{file1,file2}).Testing & Documentation:
Backward Compatibility: