[GH-ISSUE #173] Match sub-directories or allow globs/regexs with --ignore-directory #77

Closed
opened 2026-06-08 11:25:35 +03:00 by zhus · 6 comments
Owner

Originally created by @andreavaccari on GitHub (Sep 2, 2021).
Original GitHub issue: https://github.com/bootandy/dust/issues/173

Hi, thank you for your work on dust. This is a suggestion for improvement. The --ignore-directory flag currently does not match subdirectories. This would be very helpful, for example, to analyze a directory containing many repos, each containing directories to ignore: dust -f -X .git -X node_modules ~/dir-with-many-repos.

Possible improvements are:

  • Matching the specified names against a candidate's name instead of its relative path.
  • Allowing to specify patterns with globs (**/node_modules) or regexs (.*/node_modules$).

The latter is more complex but more flexible, and would make it so only one flag could/should be specified.

Unfortunately I'm not familiar with Rust. I hope you'll consider implementing this in the future. Thank you!

Originally created by @andreavaccari on GitHub (Sep 2, 2021). Original GitHub issue: https://github.com/bootandy/dust/issues/173 Hi, thank you for your work on `dust`. This is a suggestion for improvement. The `--ignore-directory` flag currently does not match subdirectories. This would be very helpful, for example, to analyze a directory containing many repos, each containing directories to ignore: `dust -f -X .git -X node_modules ~/dir-with-many-repos`. Possible improvements are: - Matching the specified names against a candidate's name instead of its relative path. - Allowing to specify patterns with globs (`**/node_modules`) or regexs (`.*/node_modules$`). The latter is more complex but more flexible, and would make it so only one flag could/should be specified. Unfortunately I'm not familiar with Rust. I hope you'll consider implementing this in the future. Thank you!
zhus closed this issue 2026-06-08 11:25:35 +03:00
Author
Owner

@bootandy commented on GitHub (Sep 2, 2021):

So just so I understand running:
dust -X node_modules ~/dir-with-many-repos.

You would like it to ignore ~/dir-with-many-repos/a/node_modules and ~/dir-with-many-repos/other_dir/sub_dir/node_modules ?

I think the above makes sense, but I'd prefer to do it with globs or regexs as in your second suggestion.

I'll add it to the todo list and I'll look at implementing it.

<!-- gh-comment-id:911362301 --> @bootandy commented on GitHub (Sep 2, 2021): So just so I understand running: `dust -X node_modules ~/dir-with-many-repos.` You would like it to ignore ~/dir-with-many-repos/a/node_modules and ~/dir-with-many-repos/other_dir/sub_dir/node_modules ? I think the above makes sense, but I'd prefer to do it with globs or regexs as in your second suggestion. I'll add it to the todo list and I'll look at implementing it.
Author
Owner

@andreavaccari commented on GitHub (Sep 3, 2021):

Yes, your example matches my suggestion.

At the moment, to exclude the two directories in your example you would have to run:

dust -X a/node_modules -X other_dir/sub_dir/node_modules ~/dir-with-many-repos

If you had several directories, you'd have to use find -exec or xargs. Being able to do this with dust alone would be great!

<!-- gh-comment-id:912560469 --> @andreavaccari commented on GitHub (Sep 3, 2021): Yes, your example matches my suggestion. At the moment, to exclude the two directories in your example you would have to run: `dust -X a/node_modules -X other_dir/sub_dir/node_modules ~/dir-with-many-repos` If you had several directories, you'd have to use `find -exec` or `xargs`. Being able to do this with `dust` alone would be great!
Author
Owner

@bootandy commented on GitHub (Sep 5, 2021):

I have just (accidentally) created this feature with this commit https://github.com/bootandy/dust/pull/174/commits/1d1bada2e402714b2c77900496616f4bca49dd5f

It will mimic the grep -v regex behaviour. Which will allow you to do dust -v node_modules

The commit isn't released yet.

<!-- gh-comment-id:913122767 --> @bootandy commented on GitHub (Sep 5, 2021): I have just (accidentally) created this feature with this commit https://github.com/bootandy/dust/pull/174/commits/1d1bada2e402714b2c77900496616f4bca49dd5f It will mimic the `grep -v regex` behaviour. Which will allow you to do `dust -v node_modules` The commit isn't released yet.
Author
Owner

@bootandy commented on GitHub (Sep 19, 2021):

Fixed with version 0.7

<!-- gh-comment-id:922461550 --> @bootandy commented on GitHub (Sep 19, 2021): Fixed with version 0.7
Author
Owner

@andreavaccari commented on GitHub (Oct 1, 2021):

Hi @bootandy, I wanted to confirm that the -v option helped tremendously with my use case.

Could you clarify the following when you have a moment?

  • With -e and -v, is it possible to match a pattern against a candidate's relative path instead of just its filename?
  • With -e, it's possible to declare multiple patterns. With -v, only the first pattern takes effect. Is this intended?

Thank you!

<!-- gh-comment-id:931787535 --> @andreavaccari commented on GitHub (Oct 1, 2021): Hi @bootandy, I wanted to confirm that the `-v` option helped tremendously with my use case. Could you clarify the following when you have a moment? - With `-e` and `-v`, is it possible to match a pattern against a candidate's relative path instead of just its filename? - With `-e`, it's possible to declare multiple patterns. With `-v`, only the first pattern takes effect. Is this intended? Thank you!
Author
Owner

@bootandy commented on GitHub (Oct 11, 2021):

@andreavaccari

With -v, only the first pattern takes effect. Is this intended?

No, that appears to be a bug I'll look into that: https://github.com/bootandy/dust/issues/188

With -e and -v, is it possible to match a pattern against a candidate's relative path

I hadn't considered relative paths when writing this. I'm not currently sure if that is possible. I'll look into it.

<!-- gh-comment-id:940215148 --> @bootandy commented on GitHub (Oct 11, 2021): @andreavaccari >With -v, only the first pattern takes effect. Is this intended? No, that appears to be a bug I'll look into that: https://github.com/bootandy/dust/issues/188 >With -e and -v, is it possible to match a pattern against a candidate's relative path I hadn't considered relative paths when writing this. I'm not currently sure if that is possible. I'll look into it.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: bootandy/archived-dust#77