Skip to content

Add --exclude flag to scan command for glob-based file exclusion#86

Open
Ibrahimrahhal wants to merge 4 commits intomainfrom
cursor/add-exclude-flag-00e8
Open

Add --exclude flag to scan command for glob-based file exclusion#86
Ibrahimrahhal wants to merge 4 commits intomainfrom
cursor/add-exclude-flag-00e8

Conversation

@Ibrahimrahhal
Copy link
Copy Markdown
Member

Summary

Adds a new --exclude CLI flag to the scan command that accepts comma-separated glob patterns to exclude files from scanning. This mirrors the existing --target flag but for exclusion.

Usage

# Exclude test files from a full scan
corgea scan --exclude "tests/**,**/*.test.ts"

# Combine with --target for precise control
corgea scan --target "src/" --exclude "**/*.md,**/*.spec.js"

# Multiple patterns
corgea scan --exclude "tests/**,docs/**,**/*.css"

Changes

  • src/main.rs: Added --exclude CLI argument to the Scan command (blast-only, matching other blast-specific flags), and passes it through to blast::run.
  • src/targets.rs: Added resolve_targets_with_exclude() which filters resolved files against user-provided exclude glob patterns. Added public helpers build_user_exclude_glob_set() and is_file_excluded() for use by the zip creation path. Added 11 unit tests.
  • src/scanners/blast.rs: Updated run() signature to accept exclude: Option<String>, passes it to both resolve_targets_with_exclude (for target validation/display) and create_zip_from_target (for zip packaging).
  • src/utils/generic.rs: Updated create_zip_from_target() to accept and apply user exclude patterns. For targeted scans, exclusion is handled by resolve_targets_with_exclude. For full repo scans (no --target), exclusion is applied during the directory walk.

Testing

  • All 18 unit tests pass (7 existing + 11 new)
  • cargo build compiles cleanly with no warnings
  • --help output correctly shows the new --exclude flag
Open in Web Open in Cursor 

cursoragent and others added 3 commits April 15, 2026 15:09
Add a new --exclude CLI flag that accepts comma-separated glob patterns
to exclude files from scanning. Works with both targeted scans (--target)
and full repository scans.

The exclude filtering is applied at three levels:
- targets.rs: resolve_targets_with_exclude filters files after target
  resolution using glob matching against repo-relative paths
- blast.rs: passes exclude through to both target resolution and zip
  creation
- generic.rs: create_zip_from_target applies user exclude patterns
  during the full-scan directory walk

Includes 11 new unit tests covering glob set construction, pattern
matching, and edge cases.

Co-authored-by: Ibrahim Rahhal <ibrahim.rahhal3636@gmail.com>
When --exclude is used without --target (full repo scan), print the
exclude patterns so the user knows they took effect.

Co-authored-by: Ibrahim Rahhal <ibrahim.rahhal3636@gmail.com>
Co-authored-by: Ibrahim Rahhal <ibrahim.rahhal3636@gmail.com>
@Ibrahimrahhal Ibrahimrahhal marked this pull request as ready for review April 15, 2026 15:20
@Ibrahimrahhal Ibrahimrahhal requested a review from yhoztak April 15, 2026 15:20
Co-authored-by: Ibrahim Rahhal <ibrahim.rahhal3636@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants