Skip to content

Commit 3309fe0

Browse files
committed
Added version option
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
1 parent e34b1cc commit 3309fe0

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Usage
4242
-func string - comma-separated functions list (default: all functions)
4343
-include-vendor - include vendor directories for show coverage (Godeps, vendor)
4444
-args - pass additional arguments for go test (for example "-short" or "-i -timeout t")
45+
-version - get version
4546

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

go-carpet.1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ options:
6262
\-func string \- comma\-separated functions list (default: all functions)
6363
\-include\-vendor \- include vendor directories for show coverage (Godeps, vendor)
6464
\-args \- pass additional arguments for go test (for example "\-short" or "\-i \-timeout t")
65+
\-version \- get version
6566
.
6667
.fi
6768
.

go-carpet.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,18 @@ import (
1616
"golang.org/x/tools/cover"
1717
)
1818

19-
const usageMessage = `go-carpet - show test coverage for Go source files
19+
const (
20+
usageMessage = `go-carpet - show test coverage for Go source files
2021
2122
usage: go-carpet [options] [paths]`
2223

24+
appVersion = "1.5"
25+
26+
// predefined go test options
27+
goTestCoverProfile = "-coverprofile"
28+
goTestCoverMode = "-covermode"
29+
)
30+
2331
var (
2432
reNewLine = regexp.MustCompile("\n")
2533
reWindowsPathFix = regexp.MustCompile(`^_\\([A-Z])_`)
@@ -29,10 +37,6 @@ var (
2937

3038
// directories for skip
3139
skipDirs = []string{"testdata"}
32-
33-
// predefined go test options
34-
goTestCoverProfile = "-coverprofile"
35-
goTestCoverMode = "-covermode"
3640
)
3741

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

354358
func main() {
359+
versionFl := flag.Bool("version", false, "get version")
355360
flag.Parse()
361+
362+
if *versionFl {
363+
fmt.Println(appVersion)
364+
os.Exit(0)
365+
}
366+
356367
config.filesFilter = grepEmptyStringSlice(strings.Split(config.filesFilterRaw, ","))
357368
config.funcFilter = grepEmptyStringSlice(strings.Split(config.funcFilterRaw, ","))
358369
additionalArgs, err := parseAdditionalArgs(config.argsRaw, []string{goTestCoverProfile, goTestCoverMode})

0 commit comments

Comments
 (0)