Skip to content

Commit

Permalink
feature add --include-lang option
Browse files Browse the repository at this point in the history
  • Loading branch information
Hideo Hattori committed Jun 1, 2016
1 parent de89ad3 commit a8e2316
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ func main() {
languages := GetDefinitionLanguages()
fileCache = make(map[string]struct{})

// setup option for include languages
IncludeLangs = make(map[string]struct{})
for _, lang := range strings.Split(opts.IncludeLang, ",") {
if _, ok := languages[lang]; ok {
IncludeLangs[lang] = struct{}{}
}
}

total := NewLanguage("TOTAL", "", "", "")
num, maxPathLen := getAllFiles(paths, languages)
headerLen := 28
Expand Down
2 changes: 2 additions & 0 deletions option.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type Options struct {
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)"`
IncludeLang string `long:"include-lang" description:"include language name (separated commas)"`
MatchDir string `long:"match-d" description:"include dir name (regex)"`
NotMatchDir string `long:"not-match-d" description:"exclude dir name (regex)"`
Debug bool `long:"debug" description:"dump debug log for developer"`
Expand All @@ -20,5 +21,6 @@ const OutputTypeSloccount string = "sloccount"

var opts Options
var ExcludeExts map[string]struct{}
var IncludeLangs map[string]struct{}
var reNotMatchDir *regexp.Regexp
var reMatchDir *regexp.Regexp
6 changes: 6 additions & 0 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ func getAllFiles(paths []string, languages map[string]*Language) (filenum, maxPa
return nil
}

if len(IncludeLangs) != 0 {
if _, ok = IncludeLangs[targetExt]; !ok {
return nil
}
}

ignore := checkMD5Sum(p)
if !opts.SkipUniqueness && ignore {
if opts.Debug {
Expand Down

0 comments on commit a8e2316

Please sign in to comment.