From 8ea699aa084e1f23f7c223eee84b777acac624c9 Mon Sep 17 00:00:00 2001 From: kota kanbe Date: Thu, 19 May 2016 15:02:17 +0900 Subject: [PATCH] Add version flag --- main.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/main.go b/main.go index 896f762e..cd3625a5 100644 --- a/main.go +++ b/main.go @@ -19,6 +19,7 @@ package main import ( "flag" + "fmt" "os" "golang.org/x/net/context" @@ -38,7 +39,15 @@ func main() { subcommands.Register(&commands.ScanCmd{}, "scan") subcommands.Register(&commands.PrepareCmd{}, "prepare") + var version = flag.Bool("v", false, "Show version") + flag.Parse() + + if *version { + fmt.Printf("%s %s\n", Name, Version) + os.Exit(int(subcommands.ExitSuccess)) + } + ctx := context.Background() os.Exit(int(subcommands.Execute(ctx))) }