From 9d9098fa977f7c8b79717a93ea82a99001ba56ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandor=20Sz=C3=BCcs?= Date: Fri, 17 May 2019 11:33:02 +0200 Subject: [PATCH] print version string (#317) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sandor Szücs --- cmd/gosec/main.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/gosec/main.go b/cmd/gosec/main.go index b0c7c4f..d740aa0 100644 --- a/cmd/gosec/main.go +++ b/cmd/gosec/main.go @@ -104,6 +104,9 @@ var ( // scan tests files flagScanTests = flag.Bool("tests", false, "Scan tests files") + // print version and quit with exit code 0 + flagVersion = flag.Bool("version", false, "Print version and quit with exit code 0") + logger *log.Logger ) @@ -219,6 +222,11 @@ func main() { // Parse command line arguments flag.Parse() + if *flagVersion { + fmt.Printf("Version: %s\nGit tag: %s\nBuild date: %s\n", Version, GitTag, BuildDate) + os.Exit(0) + } + // Ensure at least one file was specified if flag.NArg() == 0 { fmt.Fprintf(os.Stderr, "\nError: FILE [FILE...] or './...' expected\n") // #nosec