Skip to content

Commit

Permalink
WIP: separate cmd and package
Browse files Browse the repository at this point in the history
  • Loading branch information
Hideo Hattori committed Jan 16, 2018
1 parent b9d302d commit 02e6469
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 203 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Inspired by [tokei](https://github.com/Aaronepower/tokei).
## Installation

```
$ go get github.com/hhatto/gocloc
$ go get -u github.com/hhatto/gocloc/cmd/gocloc
```

## Usage
Expand Down
2 changes: 1 addition & 1 deletion bspool.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package gocloc

import "sync"

Expand Down
4 changes: 2 additions & 2 deletions file.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package gocloc

import (
"bufio"
Expand Down Expand Up @@ -30,7 +30,7 @@ func (cf ClocFiles) Less(i, j int) bool {
return cf[i].Code > cf[j].Code
}

func analyzeFile(filename string, language *Language) *ClocFile {
func analyzeFile(filename string, language *Language, opts Options) *ClocFile {
if opts.Debug {
fmt.Printf("filename=%v\n", filename)
}
Expand Down
2 changes: 1 addition & 1 deletion file_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package gocloc

import (
"io/ioutil"
Expand Down
4 changes: 2 additions & 2 deletions language.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package gocloc

import (
"bufio"
Expand Down Expand Up @@ -284,7 +284,7 @@ func getFileTypeByShebang(path string) (shebangLang string, ok bool) {
return
}

func getFileType(path string) (ext string, ok bool) {
func getFileType(path string, opts Options) (ext string, ok bool) {
ext = filepath.Ext(path)
base := filepath.Base(path)

Expand Down
2 changes: 1 addition & 1 deletion language_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package gocloc

import "testing"

Expand Down
188 changes: 0 additions & 188 deletions main.go

This file was deleted.

3 changes: 1 addition & 2 deletions option.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package gocloc

import "regexp"

Expand All @@ -19,7 +19,6 @@ const OutputTypeDefault string = "default"
const OutputTypeClocXml string = "cloc-xml"
const OutputTypeSloccount string = "sloccount"

var opts Options
var ExcludeExts map[string]struct{}
var IncludeLangs map[string]struct{}
var reNotMatchDir *regexp.Regexp
Expand Down
6 changes: 3 additions & 3 deletions utils.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package gocloc

import (
"crypto/md5"
Expand Down Expand Up @@ -55,7 +55,7 @@ func checkMD5Sum(path string) (ignore bool) {
return false
}

func getAllFiles(paths []string, languages map[string]*Language) (filenum, maxPathLen int) {
func getAllFiles(paths []string, languages map[string]*Language, opts Options) (filenum, maxPathLen int) {
maxPathLen = 0
for _, root := range paths {
vcsInRoot := isVCSDir(root)
Expand All @@ -80,7 +80,7 @@ func getAllFiles(paths []string, languages map[string]*Language) (filenum, maxPa
return nil
}

if ext, ok := getFileType(path); ok {
if ext, ok := getFileType(path, opts); ok {
if targetExt, ok := Exts[ext]; ok {
// check exclude extension
if _, ok := ExcludeExts[targetExt]; ok {
Expand Down
2 changes: 1 addition & 1 deletion utils_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package gocloc

import "testing"

Expand Down
2 changes: 1 addition & 1 deletion xml.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package gocloc

import (
"encoding/xml"
Expand Down

0 comments on commit 02e6469

Please sign in to comment.