Skip to content

Commit d2c384b

Browse files
committed
add version flag
1 parent e37710e commit d2c384b

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed

.goreleaser.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
version: 2
2+
builds:
3+
- main: ./cmd/connector/main.go
4+
goos:
5+
- darwin
6+
- linux
7+
- windows
8+
env:
9+
- CGO_ENABLED=0
10+
ldflags:
11+
- "-s -w -X 'main.version={{ .Tag }}'"
12+
checksum:
13+
name_template: checksums.txt
14+
archives:
15+
- name_template: >-
16+
{{ .ProjectName }}_
17+
{{- .Version }}_
18+
{{- title .Os }}_
19+
{{- if eq .Arch "amd64" }}x86_64
20+
{{- else if eq .Arch "386" }}i386
21+
{{- else }}{{ .Arch }}{{ end }}
22+
changelog:
23+
sort: asc
24+
use: github
25+
filters:
26+
exclude:
27+
- '^docs:'
28+
- '^test:'
29+
- '^go.mod:'
30+
- '^.github:'
31+
- Merge branch

cmd/benchi/main.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ import (
4141
)
4242

4343
var (
44-
configPathFlag = flag.String("config", "", "path to the benchmark config file")
45-
outPathFlag = flag.String("out", "./results/${now}", "path to the output folder")
46-
toolsFlag = internal.StringsFlag("tool", nil, "filter tool to be tested (can be provided multiple times)")
47-
testsFlag = internal.StringsFlag("tests", nil, "filter test to run (can be provided multiple times)")
44+
configPathFlag = flag.String("config", "", "Path to the benchmark config file")
45+
outPathFlag = flag.String("out", "./results/${now}", "Path to the output folder")
46+
toolsFlag = internal.StringsFlag("tool", nil, "Filter tool to be tested (can be provided multiple times)")
47+
testsFlag = internal.StringsFlag("tests", nil, "Filter test to run (can be provided multiple times)")
48+
49+
versionFlag = flag.Bool("v", false, "Print version")
4850
)
4951

5052
// version is set at build time.
@@ -60,6 +62,11 @@ func main() {
6062
func mainE() error {
6163
flag.Parse()
6264

65+
if *versionFlag {
66+
fmt.Println("benchi", version)
67+
return nil
68+
}
69+
6370
if configPathFlag == nil || strings.TrimSpace(*configPathFlag) == "" {
6471
return fmt.Errorf("config path is required")
6572
}

0 commit comments

Comments
 (0)