add version flag
This commit is contained in:
parent
2decb499f2
commit
961ed9e35f
1 changed files with 8 additions and 0 deletions
8
cli.go
8
cli.go
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/jessevdk/go-flags"
|
"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"`
|
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"`
|
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"`
|
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 globalOptions GlobalOptions
|
||||||
var parser = flags.NewParser(&globalOptions, flags.Default)
|
var parser = flags.NewParser(&globalOptions, flags.Default)
|
||||||
|
|
||||||
|
var version = "v0.2"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
globalOptions.Version = func() {
|
||||||
|
fmt.Println("dockviz", version)
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
if _, err := parser.Parse(); err != nil {
|
if _, err := parser.Parse(); err != nil {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue