Skip to content

Commit

Permalink
Added version option
Browse files Browse the repository at this point in the history
Changes:
 * Added -args option for pass additional options to go test
 * Added -version option
 * Added man page
 * Added auto deploy from Travis CI to github releases
  • Loading branch information
msoap committed Feb 12, 2017
1 parent e34b1cc commit 3309fe0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Usage
-func string - comma-separated functions list (default: all functions)
-include-vendor - include vendor directories for show coverage (Godeps, vendor)
-args - pass additional arguments for go test (for example "-short" or "-i -timeout t")
-version - get version

For view in less, use `-R` option:

Expand Down
1 change: 1 addition & 0 deletions go-carpet.1
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ options:
\-func string \- comma\-separated functions list (default: all functions)
\-include\-vendor \- include vendor directories for show coverage (Godeps, vendor)
\-args \- pass additional arguments for go test (for example "\-short" or "\-i \-timeout t")
\-version \- get version
.
.fi
.
Expand Down
21 changes: 16 additions & 5 deletions go-carpet.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,18 @@ import (
"golang.org/x/tools/cover"
)

const usageMessage = `go-carpet - show test coverage for Go source files
const (
usageMessage = `go-carpet - show test coverage for Go source files
usage: go-carpet [options] [paths]`

appVersion = "1.5"

// predefined go test options
goTestCoverProfile = "-coverprofile"
goTestCoverMode = "-covermode"
)

var (
reNewLine = regexp.MustCompile("\n")
reWindowsPathFix = regexp.MustCompile(`^_\\([A-Z])_`)
Expand All @@ -29,10 +37,6 @@ var (

// directories for skip
skipDirs = []string{"testdata"}

// predefined go test options
goTestCoverProfile = "-coverprofile"
goTestCoverMode = "-covermode"
)

func getDirsWithTests(includeVendor bool, roots ...string) (result []string, err error) {
Expand Down Expand Up @@ -352,7 +356,14 @@ func init() {
}

func main() {
versionFl := flag.Bool("version", false, "get version")
flag.Parse()

if *versionFl {
fmt.Println(appVersion)
os.Exit(0)
}

config.filesFilter = grepEmptyStringSlice(strings.Split(config.filesFilterRaw, ","))
config.funcFilter = grepEmptyStringSlice(strings.Split(config.funcFilterRaw, ","))
additionalArgs, err := parseAdditionalArgs(config.argsRaw, []string{goTestCoverProfile, goTestCoverMode})
Expand Down

0 comments on commit 3309fe0

Please sign in to comment.