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

Add option to filter files using glob patterns #12

Merged
merged 6 commits into from
Feb 7, 2023

Conversation

jprochazk
Copy link
Contributor

@jprochazk jprochazk commented Feb 6, 2023

Fixes #10

Three new flags were added:

  • -g/--glob, which allows specifying a glob pattern to use when filtering files
  • --iglob, which is like --glob, but the pattern is case insensitive
  • --glob-case-insensitive, which makes all --glob to behave like --iglob

I couldn't think of a good way to test this under tree/test.rs (because the big code change is in cli), so the tests for this feature were added as E2E tests under /tests. They execute erdtree using cargo with the given args, and compare the output (with ansi escapes stripped) against string literals (de-intended using indoc).

Because the glob pattern may be invalid (see https://docs.rs/globset/latest/globset/#syntax), parsing Clargs is now fallible (done by replacing the implementation of From<&Clargs> with TryFrom<&Clargs>.

image

These args used to build `Overrides`, which are passed to the
`WalkBuilder` which is used to traverse directories. Because the
glob patterns may be invalid, parsing the `Clargs` is now fallible.
@solidiquis
Copy link
Owner

This looks good! Do tests pass for you locally by chance? It is failing here

@jprochazk
Copy link
Contributor Author

Yes, they are passing locally. The globbing seems to work correctly, but the output lists the files in a different order. I added --num-threads 1 and --order filename to try make the order deterministic.

@solidiquis solidiquis merged commit f078ed4 into solidiquis:master Feb 7, 2023
@solidiquis
Copy link
Owner

Fantastic, thanks for the feature add! I will include it in the release hopefully later this week.

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.

[feature] Option to filter files
2 participants