Add version output support when built

This commit is contained in:
Tony Blyler 2016-05-16 20:12:26 -04:00
parent 659fca62a8
commit 8f1aa0651c
No known key found for this signature in database
GPG key ID: 25C9D3A655D1A65C

View file

@ -2,6 +2,7 @@ package main
import ( import (
"flag" "flag"
"fmt"
"github.com/tblyler/hoarder/queue" "github.com/tblyler/hoarder/queue"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
"io/ioutil" "io/ioutil"
@ -10,10 +11,19 @@ import (
"os/signal" "os/signal"
) )
var buildVersion = "Unknown"
var buildDate = "Unknown"
func main() { func main() {
version := flag.Bool("version", false, "display version info")
configPath := flag.String("config", "", "path to the config file") configPath := flag.String("config", "", "path to the config file")
flag.Parse() flag.Parse()
if *version {
fmt.Printf("%s\n%s\n", buildVersion, buildDate)
os.Exit(0)
}
logger := log.New(os.Stdout, "hoarder ", log.LstdFlags) logger := log.New(os.Stdout, "hoarder ", log.LstdFlags)
if *configPath == "" { if *configPath == "" {