Giter VIP home page Giter VIP logo

Comments (16)

boyter avatar boyter commented on May 18, 2024 1

Sounds good. Ill add that in now. Thanks for sharing it.

from scc.

boyter avatar boyter commented on May 18, 2024

Sounds interesting. Would it not be acceptable in this case to have them combined into a single regex though?

scc --not-match ".*\.csv|specialDirectory/.*\.txt" .

The above is not tested BTW

from scc.

andyfitzgerald avatar andyfitzgerald commented on May 18, 2024

That's certainly an option; however, I propose this as an enhancement to improve readability and maintainability of the code invoking scc.

Imagine a project that embeds scc in a script (make, bash, etc). There will likely be a few variables, or an array variable, containing special cases to ignore. Please see a contrived example below.

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.

from scc.

boyter avatar boyter commented on May 18, 2024

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.

from scc.

andyfitzgerald avatar andyfitzgerald commented on May 18, 2024

Assuming that you mean the command line arguments to scc, my guess would be that you could re-use the solution for #61 or what is currently done for --exclude-dir arguments. Multiple --exclude-dir arguments appears to work in my local tests.

from scc.

boyter avatar boyter commented on May 18, 2024

Neat. I'm having a look at this now.

from scc.

boyter avatar boyter commented on May 18, 2024

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.

from scc.

dbaggerman avatar dbaggerman commented on May 18, 2024

Cobra supports StringSlice flags: https://godoc.org/github.com/spf13/pflag#StringSlice

from scc.

boyter avatar boyter commented on May 18, 2024

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 ?

from scc.

dbaggerman avatar dbaggerman commented on May 18, 2024

I'm busy with other stuff right now, but I can pick it up later if you don't get to it.

from scc.

boyter avatar boyter commented on May 18, 2024

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.

from scc.

boyter avatar boyter commented on May 18, 2024

@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.

from scc.

andyfitzgerald avatar andyfitzgerald commented on May 18, 2024

I tested this morning with scc version 2.4.0 and found the results identical between ...

  1. single --not-match argument: complex regex string where the different regex are joined with |
  2. multiple --not-match arguments: the same regex strings used above, except passed in as multiple arguments without the | operator

Looks resolved to me. Thanks for the fast work @dbaggerman and @boyter! I'm sure everyone will appreciate the improved readability in their scc wrapper scripts.

from scc.

boyter avatar boyter commented on May 18, 2024

@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.

from scc.

andyfitzgerald avatar andyfitzgerald commented on May 18, 2024

Thanks for asking. My test cases were ...

single --not-match argument: complex regex string where the different regex are joined with |

scc --not-match="(.*\.hex|.*\.d|.*\.o|.*\.csv|^(./)?[0-9]{8}_.*)" .

multiple --not-match arguments: the same regex strings used above, except passed in as multiple arguments without the | operator

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.

from scc.

boyter avatar boyter commented on May 18, 2024

Added in bfef56a and going to close this down now since all appears well. Thanks for responding with the test case you used.

from scc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.