From c1a4e30bbd7c215ef330910d0a151cd58853472b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Fri, 26 Jan 2018 18:21:40 -0800 Subject: [PATCH] Add --version flag This is useful to get the version from the compiled binary without the need to run it --- main.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/main.go b/main.go index 2effd3671..f788eab83 100644 --- a/main.go +++ b/main.go @@ -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()