Add -version flag to print current version

This commit is contained in:
Joël Stemmer 2019-10-04 00:07:33 +01:00
parent 984a47ca6b
commit b2b06e7a1e

View File

@ -9,16 +9,28 @@ import (
"github.com/jstemmer/go-junit-report/parser" "github.com/jstemmer/go-junit-report/parser"
) )
var (
Version = "v0.9.1-dev"
Revision = "HEAD"
BuildTime string
)
var ( var (
noXMLHeader = flag.Bool("no-xml-header", false, "do not print xml header") noXMLHeader = flag.Bool("no-xml-header", false, "do not print xml header")
packageName = flag.String("package-name", "", "specify a package name (compiled test have no package name in output)") packageName = flag.String("package-name", "", "specify a package name (compiled test have no package name in output)")
goVersionFlag = flag.String("go-version", "", "specify the value to use for the go.version property in the generated XML") goVersionFlag = flag.String("go-version", "", "specify the value to use for the go.version property in the generated XML")
setExitCode = flag.Bool("set-exit-code", false, "set exit code to 1 if tests failed") setExitCode = flag.Bool("set-exit-code", false, "set exit code to 1 if tests failed")
version = flag.Bool("version", false, "print version")
) )
func main() { func main() {
flag.Parse() flag.Parse()
if *version {
fmt.Printf("go-junit-report %s %s (%s)\n", Version, BuildTime, Revision)
return
}
if flag.NArg() != 0 { if flag.NArg() != 0 {
fmt.Fprintf(os.Stderr, "%s does not accept positional arguments\n", os.Args[0]) fmt.Fprintf(os.Stderr, "%s does not accept positional arguments\n", os.Args[0])
flag.Usage() flag.Usage()