Add version information

This commit is contained in:
Enrico Stahn 2018-02-19 19:49:25 +11:00
parent 422448006e
commit 058139cea2
No known key found for this signature in database
GPG key ID: 5263621C269A50DE
3 changed files with 13 additions and 2 deletions

View file

@ -30,6 +30,7 @@ var log = logrus.New()
var (
cfgFile string
logLevel string
Version string
)
// RootCmd represents the base command when called without any subcommands

View file

@ -25,7 +25,7 @@ var versionCmd = &cobra.Command{
Short: "Print the version number of php-fpm_exporter",
Long: `All software has versions. This is php-fpm_exporter's'`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("php-fpm_exporter v0.9 -- HEAD")
fmt.Printf("php-fpm_exporter %v\n", Version)
},
}

12
main.go
View file

@ -13,8 +13,18 @@
package main
import "github.com/hipages/php-fpm_exporter/cmd"
import (
"fmt"
"github.com/hipages/php-fpm_exporter/cmd"
)
var (
version = "dev"
commit = "none"
date = "unknown"
)
func main() {
cmd.Version = fmt.Sprintf("%v, commit %v, built at %v", version, commit, date)
cmd.Execute()
}