Skip to content

Commit

Permalink
Print build info in the --help output.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaqx0r committed Jun 28, 2017
1 parent 0b263d6 commit 174a645
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -68,7 +68,7 @@ version := $(shell git describe --tags)
revision := $(shell git rev-parse HEAD)

install mtail: $(GOFILES) .dep-stamp
go install -ldflags "-X main.version=${version} -X main.revision=${revision}"
go install -ldflags "-X main.Version=${version} -X main.Revision=${revision}"

vm/parser.go: vm/parser.y .gen-dep-stamp
go generate -x ./vm
Expand Down
14 changes: 13 additions & 1 deletion main.go
Expand Up @@ -5,6 +5,8 @@ package main

import (
"flag"
"fmt"
"os"
"runtime"
"strconv"
"strings"
Expand Down Expand Up @@ -34,12 +36,22 @@ var (
var (
// Externally supplied by the linker
Version string
Revision string
GoVersion = runtime.Version()
)

func buildInfo() string {
return fmt.Sprintf("mtail version %s git revision %s go version %s", Version, Revision, GoVersion)
}

func main() {
glog.Infof("Mtail version %s go version %s", Version, GoVersion)
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "%s\n", buildInfo())
fmt.Fprintf(os.Stderr, "\nUsage:\n")
flag.PrintDefaults()
}
flag.Parse()
glog.Info(buildInfo())
if *progs == "" {
glog.Exitf("No mtail program directory specified; use -progs")
}
Expand Down

0 comments on commit 174a645

Please sign in to comment.