From 961ed9e35f0f9d75993151a14c72ffa66b8b439f Mon Sep 17 00:00:00 2001 From: Nate Jones Date: Thu, 21 May 2015 22:33:11 -0700 Subject: [PATCH] add version flag --- cli.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cli.go b/cli.go index aab4dc9..e5e72fc 100644 --- a/cli.go +++ b/cli.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "os" "github.com/jessevdk/go-flags" @@ -12,12 +13,19 @@ type GlobalOptions struct { TLSKey string `long:"tlskey" value-name:"~/.docker/key.pem" description:"Path to TLS key file"` TLSVerify bool `long:"tlsverify" description:"Use TLS and verify the remote"` Host string `long:"host" short:"H" value-name:"unix:///var/run/docker.sock" description:"Docker host to connect to"` + Version func() `long:"version" short:"v" description:"Display version information."` } var globalOptions GlobalOptions var parser = flags.NewParser(&globalOptions, flags.Default) +var version = "v0.2" + func main() { + globalOptions.Version = func() { + fmt.Println("dockviz", version) + os.Exit(0) + } if _, err := parser.Parse(); err != nil { os.Exit(1) }