Add --version flag

This is useful to get the version from the compiled binary without the need to run it
This commit is contained in:
Łukasz Mierzwa
2018-01-26 18:21:40 -08:00
parent b88aa4a1c9
commit c1a4e30bbd

View File

@@ -12,6 +12,7 @@ import (
"github.com/cloudflare/unsee/internal/config"
"github.com/cloudflare/unsee/internal/models"
"github.com/cloudflare/unsee/internal/transform"
"github.com/spf13/pflag"
"github.com/DeanThompson/ginpprof"
"github.com/gin-contrib/gzip"
@@ -109,6 +110,13 @@ func setupLogger() {
}
func main() {
printVersion := pflag.Bool("version", false, "Print version and exit")
pflag.Parse()
if *printVersion {
fmt.Println(version)
return
}
config.Config.Read()
setupLogger()