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

support glob in --ignore or some way to specify relative directories for SEARCH_IN_DIRS #12

Closed
bjrmatos opened this issue Nov 12, 2024 · 8 comments · Fixed by #13
Closed

Comments

@bjrmatos
Copy link

hi! thanks for such amazing cli, it is really fast and i am using it everyday!

as part of my normal usage, i usually work in node.js based projects, and execute file searches in these projects. i would like to speed the search even more by ignoring certain folders like node_modules, or .git.

i was trying to use hunt --hidden --ignore node_modules foo.js <path-to-my-project> but this does not work, I've realized that the expected format for other --ignore option is to pass a list of full paths. (FYI i use --hidden because i usually search for configuration files that start with dot


i think supporting relative paths for --ignore would be a nice addition, and i would be still easy to use. the way i think it should work like this:

hunt --hidden --ignore node_modules foo.js <path-to-my-project>

this will skip the search for paths like <path-to-my-project>/node_modules, or <path-to-my-project>/src/directory/node_modules, so basically any path inside <path-to-my-project> that contains the directory node_modules will be skipped. it would be amazing that this also works for all directories passed to SEARCH_IN_DIRS

@LyonSyonII
Copy link
Owner

The expected format is to pass a list of full paths

After reading the code that handles the ignores, relative paths should be supported, but only relative to the current location.
The logic is also a bit strange at the moment, it'll need a checkup, as it probably can cause a few bugs.

Skip any path that contains the directory...

If it's only a directory/file, then it can be added without too much changes.
But full glob support will not be added, as it requires changing too much, making searches noticeably slower.

Thank you for opening the issue! I'll try to look into solving it in the near future.

@bjrmatos
Copy link
Author

But full glob support will not be added, as it requires changing too much, making searches noticeably slower.

yes, makes sense, no need for full glob support. i am more than happy if the current --ignore directories work with relative paths.

thanks for checking it.

@LyonSyonII
Copy link
Owner

Should be good now!
Could you try it and check if it's really fixed?

@bjrmatos
Copy link
Author

bjrmatos commented Nov 13, 2024

thanks, that was fast! is this available from cargo? i tried to install from it but it still downloads 2.4.0

@LyonSyonII
Copy link
Owner

Should be now

@bjrmatos
Copy link
Author

it is working! this will dramatically improve my day to day usage, thank you!

a last question, is there any way to know the paths the hunt traverses? my use case is that i want to understand which files/directories are being traversed so i can create a good ignore list. i was thinking the verbose option does this but it just shows when errors are found.

@LyonSyonII
Copy link
Owner

If you run hunt without any arguments (flags are allowed) it'll show all paths it finds.

@bjrmatos
Copy link
Author

awesome, thanks for the tip! and thanks again for quick implementation of the --ignore, have a good day!

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 a pull request may close this issue.

2 participants