Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--ignore patterns now include directory names unless --ignore-files-only #30

Merged
merged 5 commits into from
Feb 14, 2025

Conversation

nmpowell
Copy link
Contributor

Closes #7 closes #29 .

Changes the default behaviour of --ignore to also ignore directory names matching the pattern. I thought this would be the default behaviour, and apparently others did as well. You can revert to the original behaviour by adding the --include-directories flag. Thus for:

my_directory/
├── file1.txt
├── file2.txt
├── .hidden_file.txt
├── temp.log
└── subdirectory/
    └── file3.txt

files-to-prompt my_directory --ignore "sub*" will exclude file3.txt, files-to-prompt my_directory --ignore "sub*" --include-directories will not.

@nmpowell nmpowell marked this pull request as ready for review October 15, 2024 23:08
@DhruvParikh1
Copy link

Thank you for this; it will be especially useful for many projects with a "node_modules" directory (which contains a million subdirectories). I am assuming the command for that would be files-to-prompt . --ignore "node_modules*"?

Good work

@nmpowell
Copy link
Contributor Author

nmpowell commented Oct 16, 2024

I am assuming the command for that would be files-to-prompt . --ignore "node_modules*"?

Yes, just tested locally. "node_modules" (full name with or without *), "node*", "*modules", etc. No support afaict for the trailing slash, i.e. --ignore node_modules/ won't work. That's down to / not being output from os.walk.

Edit to add: For that matter, no path patterns with a slash, i.e. --ignore "node_modules/some_subdirectory" will work from this PR, because of how os.walk parses the tree. Only the standalone directory name.

@elasticdotventures
Copy link

is this ready for merge?

@thedch
Copy link

thedch commented Feb 12, 2025

@simonw Could we merge this sort of functionality? Would be very helpful

@voxmenthe
Copy link

I was thinking of adding this functionality myself! Glad to see someone has already done it.

@elasticdotventures
Copy link

elasticdotventures commented Feb 13, 2025

while I like this utility, i'm concerned about it's authors commitment to maintenance (*@simonw you should appoint some maintainers or archive this 🙏🏻 ).

In the meantime I've migrated my own workflows to the rust cargo based yek

https://github.com/bodo-run/yek/

@simonw
Copy link
Owner

simonw commented Feb 14, 2025

I'm going to make one change to this. The pairing of --ignore and --include-directories feels non-obvious to me - --include-directories only affects --ignore but the names don't hint at that very well.

I'm going to change the --include-directories option to --ignore-files-only instead (thanks Claude).

@simonw simonw changed the title Ignore path patterns --ignore patterns now include directory names unless --ignore-files-only Feb 14, 2025
@simonw simonw merged commit acbe107 into simonw:main Feb 14, 2025
5 checks passed
simonw added a commit that referenced this pull request Feb 14, 2025
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.

Can't find a way to ignore the node_modules directory not ignoring my venv folder
6 participants