Merge pull request #224 from cloudflare/version

Add --version flag
This commit is contained in:
Łukasz Mierzwa
2018-01-27 09:39:57 -08:00
committed by GitHub
2 changed files with 8 additions and 2 deletions

View File

@@ -79,8 +79,6 @@ func init() {
func (config *configSchema) Read() {
v := viper.New()
pflag.Parse()
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
pflag.Parse()
v.BindPFlags(pflag.CommandLine)

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()