From 780c817e19dbf27f67bb2f94830ffb9e0cd70bc2 Mon Sep 17 00:00:00 2001 From: Tanabe Ken-ichi Date: Tue, 8 Sep 2020 17:42:31 +0900 Subject: [PATCH] Add -version flag to show version and exit with zero --- main.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/main.go b/main.go index 8c01b67..645a420 100644 --- a/main.go +++ b/main.go @@ -26,6 +26,7 @@ func main() { appID := flag.Int64("app-id", 0, "App ID") instID := flag.Int64("inst-id", 0, "Installation ID") export := flag.Bool("export", false, "show token as 'export GITHUB_TOKEN=...'") + showVersion := flag.Bool("version", false, "show version info") origUsage := flag.Usage flag.Usage = func() { @@ -37,6 +38,13 @@ func main() { flag.Parse() + // See https://github.com/golang/go/issues/37533 + // I decided to implement -version flag to return 0 + if *showVersion { + flag.Usage() + os.Exit(0) + } + if *appID == 0 || *instID == 0 { fmt.Fprintf(os.Stderr, "App ID and Installation ID are required.\n\n") flag.Usage()