From 8f1aa0651c8fe1f7f112981992d0afb3997281a3 Mon Sep 17 00:00:00 2001 From: Tony Blyler Date: Mon, 16 May 2016 20:12:26 -0400 Subject: [PATCH] Add version output support when built --- cmd/hoarder/main.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmd/hoarder/main.go b/cmd/hoarder/main.go index bed490b..1054011 100644 --- a/cmd/hoarder/main.go +++ b/cmd/hoarder/main.go @@ -2,6 +2,7 @@ package main import ( "flag" + "fmt" "github.com/tblyler/hoarder/queue" "gopkg.in/yaml.v2" "io/ioutil" @@ -10,10 +11,19 @@ import ( "os/signal" ) +var buildVersion = "Unknown" +var buildDate = "Unknown" + func main() { + version := flag.Bool("version", false, "display version info") configPath := flag.String("config", "", "path to the config file") flag.Parse() + if *version { + fmt.Printf("%s\n%s\n", buildVersion, buildDate) + os.Exit(0) + } + logger := log.New(os.Stdout, "hoarder ", log.LstdFlags) if *configPath == "" {