Skip to content

Commit

Permalink
add --not-match-d option
Browse files Browse the repository at this point in the history
  • Loading branch information
Hideo Hattori committed Apr 4, 2016
1 parent 9e80680 commit 522c4f8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
11 changes: 11 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"regexp"
"sort"
"strings"

Expand Down Expand Up @@ -55,6 +56,12 @@ func getAllFiles(paths []string, languages map[string]*Language) (filenum, maxPa
}

p := filepath.Join(root, rel)

// check not-match directory
if reNotMatchDir != nil && reNotMatchDir.MatchString(p) {
return nil
}

if strings.HasPrefix(root, ".") || strings.HasPrefix(root, "./") {
p = "./" + p
}
Expand Down Expand Up @@ -108,6 +115,10 @@ func main() {
}
}

if opts.NotMatchDir != "" {
reNotMatchDir = regexp.MustCompile(opts.NotMatchDir)
}

// define languages
action_script := NewLanguage("ActionScript", "//", "/*", "*/")
asm := NewLanguage("Assembly", "", "", "")
Expand Down
12 changes: 8 additions & 4 deletions option.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package main

import "regexp"

type Options struct {
Byfile bool `long:"by-file" description:"report results for every source file encountered."`
SortTag string `long:"sort" default:"code" description:"sort based on a certain column"`
OutputType string `long:"output-type" default:"default" description:"output type [values: default,cloc-xml,sloccount]"`
ExcludeExt string `long:"exclude-ext" description:"exclude file name extensions (separated commas)"`
Byfile bool `long:"by-file" description:"report results for every source file encountered."`
SortTag string `long:"sort" default:"code" description:"sort based on a certain column"`
OutputType string `long:"output-type" default:"default" description:"output type [values: default,cloc-xml,sloccount]"`
ExcludeExt string `long:"exclude-ext" description:"exclude file name extensions (separated commas)"`
NotMatchDir string `long:"not-match-d" description:"exclude dir name (regex)"`
}

const OutputTypeDefault string = "default"
Expand All @@ -13,3 +16,4 @@ const OutputTypeSloccount string = "sloccount"

var opts Options
var ExcludeExts map[string]struct{}
var reNotMatchDir *regexp.Regexp

0 comments on commit 522c4f8

Please sign in to comment.