Add exclude option
Added --exclude option that mimics ctag's exclude flag. The pattern is expected to be a shell glob pattern (which is what Go's filepath.Match method expects). It can be set multiple times to set several filters. Once the file list is built, the patterns will be applied to each file to filter out any names that match the exclude patterns before processing.
Thanks, this is a nice feature to add.
I've had some trouble trying to match subdirectories in a long path. It looks like this is because filepath.Match does not handle the ** wildcard to match multiple directories in a row, which makes it less useful on directory matching unfortunately.
I've got a few minor comments I'll leave inline, other than that it looks good. If you could fix those and squash your commits I'll merge it.
I see you opened issue golang/go#11862 in the Go project regarding the ** wildcard. I'll keep an eye on it.
Changes made and squashed commits
@jstemmer Just wanted to remind you that this is ready to go.
Thanks - no worries. Looks like the feature request for the glob handling ** is being implemented too. I think it should just work when it lands but will be sure to test it when it does.
the double star glob seems to have been rejected from the go-stdlib
I propose to use regex.MatchString() with a path conversion filepath.ToSlash(), instead of filepath.Match().
filepath.ToSlash() will keep the exclude regex consistent across platforms.
regex.MatchString() will sidestep the issue of not being able to match a file after traversing an arbitrary number of directories.
The drawbacks are:
The regular expressions won't look as pretty.
Directory names and file names are not distinguishable.
here's a self contained example of what I am proposing.
https://gist.github.com/wobbol/e60d0bf27cc6fa255bde1864b3513645