-
-
Notifications
You must be signed in to change notification settings - Fork 248
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
Allow passing multiple regex (--not-match) #67
Comments
Sounds interesting. Would it not be acceptable in this case to have them combined into a single regex though?
The above is not tested BTW |
That's certainly an option; however, I propose this as an enhancement to improve readability and maintainability of the code invoking Imagine a project that embeds SCC_REGEX_EXCLUDES := \
".*\.csv" \
"specialDirectory/.*\.txt" \
".*\build.*" \
"otherSpecialDirectoryPattern" \
".*\.hex" \
"more and more tedious regex.*"
SCC_EXCLUDES_REGEX_STR := $(addprefix --not-match=, $(SCC_REGEX_EXCLUDES))
...
target:
scc $(SCC_EXCLUDES_REGEX_STR) directoryToScan In this way, it's easier to read and maintain the script. It also simple to add cases for developers who are not regex experts. You could argue that the encapsulating script could assemble a regex in a way that's better for maintainability, but I would counter that it's prone to error. |
That's fair enough. I tend to do multiples when using grep in some situations as well. I am not that familiar with cobra which does the argument parsing but I suspect this should be possible. |
Assuming that you mean the command line arguments to |
Neat. I'm having a look at this now. |
So this works very differently to the way #61 does because that worked outside of Cobra. Not sure if https://github.com/spf13/cobra supports multiple of the same arguments to it. I didn't see anything on the main page anyway. Will have to look into that further. |
Cobra supports |
Oh nice. Well that answers that question then. I literally just stepped off a plane after 20 hours of flying and didn't feel like digging into the docs. Ill have a look at implementing this then, unless you want to do it @dbaggerman ? |
I'm busy with other stuff right now, but I can pick it up later if you don't get to it. |
No worries. My plan is to look into the git ignore issue some more as the main thing for me to tinker with for the next chunk of time I block out for this. |
@andyfitzgerald This has been merged into master. If you want to try it out you can build from there and give it a go, and all credit to @dbaggerman for actually implementing. |
I tested this morning with
Looks resolved to me. Thanks for the fast work @dbaggerman and @boyter! I'm sure everyone will appreciate the improved readability in their |
@andyfitzgerald if you could let me know what test you used ill add it into the test suite. If not no worries ill just make one of my own, but happy to have yours in there. |
Thanks for asking. My test cases were ...
scc --not-match="(.*\.hex|.*\.d|.*\.o|.*\.csv|^(./)?[0-9]{8}_.*)" .
scc --not-match=".*\.hex" --not-match=".*\.d" --not-match=".*\.o" --not-match=".*\.csv" --not-match="^(./)?[0-9]{8}_.*" . Then I simply verified that I got the same file type counts and COCOMO outputs for a directory containing both source files and unwanted files matching those patterns. |
Sounds good. Ill add that in now. Thanks for sharing it. |
Added in bfef56a and going to close this down now since all appears well. Thanks for responding with the test case you used. |
Consider accepting multiple regular expressions instead of just one. Example
Currently
scc
just uses the last specified regex (--not-match) option.The text was updated successfully, but these errors were encountered: