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 globbing pattern matching for search_path (Replaces #179) #215

Merged
merged 2 commits into from
Dec 17, 2024

Conversation

anya004
Copy link
Contributor

@anya004 anya004 commented Oct 30, 2024

Fixes #165

This PR adds support for glob patterns, controlled by a new globbing flag. When enabled (-globbing), the tool will use glob pattern matching to locate files and directories.

I decided to implement a flag so that the user is aware of the behaviour in case they have some unconventional filenames.

When globbing is enabled, matched paths are dynamically added to the searchPath array for further processing.

@kehoecj kehoecj self-requested a review October 31, 2024 02:28
@kehoecj kehoecj added hacktoberfest-accepted Valid PR Hacktoberfest PR hacktoberfest 🎃 Hacktoberfest 2024 pr-action-requested PR is awaiting feedback from the submitting developer labels Oct 31, 2024
Copy link
Collaborator

@kehoecj kehoecj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't get globbing to work. Used the examples in the unit tests locally and they did not produce a result. Need to provide some examples section in the README and a link to glob patterns

Copy link
Collaborator

@kehoecj kehoecj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't get globbing to work. Used the examples in the unit tests locally and they did not produce a result. Need to provide some examples section in the README and a link to glob patterns

@anya004
Copy link
Contributor Author

anya004 commented Oct 31, 2024

@kehoecj were you using double quotes around the pattern string?

@kehoecj
Copy link
Collaborator

kehoecj commented Nov 14, 2024

@kehoecj were you using double quotes around the pattern string?

@anya004

Even using double quotes I still can't seem to get this to work at all. Here's what I've tried and get no output:

  • validator --globbing "/test/**/*.json"
  • `validator --globbing "/test/fixtures/subdir2/*.json"

If I point directly to the file it does run correctly:

validator --globbing "/test/fixtures/subdir2/good.json"
    ✓ /test/fixtures/subdir2/good.json

@kehoecj
Copy link
Collaborator

kehoecj commented Dec 3, 2024

@kehoecj were you using double quotes around the pattern string?

@anya004

Even using double quotes I still can't seem to get this to work at all. Here's what I've tried and get no output:

  • validator --globbing "/test/**/*.json"
  • `validator --globbing "/test/fixtures/subdir2/*.json"

If I point directly to the file it does run correctly:

validator --globbing "/test/fixtures/subdir2/good.json"
    ✓ /test/fixtures/subdir2/good.json

@anya004 Any guidance on this?

@anya004
Copy link
Contributor Author

anya004 commented Dec 4, 2024

Hey @kehoecj !

To be honest, I was running it as go run cmd/validator/validator.go --reporter=json -globbing "test/**/*.json"

Now I have also tried creating a standalone executable with go build -o validatordev in the cmd/validator folder. After which, I was able to run ./cmd/validator/validatordev -globbing "test/**/*.json" and it produces the expected output.

Did I miss a step of creating an executable somewhere? I am new to go projects and would appreciate your guidance!

Maybe you could also try running echo "test/**/*.json" in your environment to see what that responds with?

> echo "test/**/*.json"
> test/**/*.json

@anya004
Copy link
Contributor Author

anya004 commented Dec 10, 2024

@kehoecj have you had a chance to check the output?

@kehoecj
Copy link
Collaborator

kehoecj commented Dec 17, 2024

@kehoecj have you had a chance to check the output?

It's working now, approved!

Copy link
Collaborator

@kehoecj kehoecj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM @anya004 , thanks for the PR!

@kehoecj kehoecj merged commit 689525f into Boeing:main Dec 17, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest 🎃 Hacktoberfest 2024 hacktoberfest-accepted Valid PR Hacktoberfest PR pr-action-requested PR is awaiting feedback from the submitting developer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE REQUEST] Add support for glob patterns
2 participants