print version string (#317)

Signed-off-by: Sandor Szücs <sandor.szuecs@zalando.de>
This commit is contained in:
Sandor Szücs 2019-05-17 11:33:02 +02:00 committed by Cosmin Cojocar
parent ee80733faf
commit 9d9098fa97

View file

@ -104,6 +104,9 @@ var (
// scan tests files // scan tests files
flagScanTests = flag.Bool("tests", false, "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 logger *log.Logger
) )
@ -219,6 +222,11 @@ func main() {
// Parse command line arguments // Parse command line arguments
flag.Parse() 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 // Ensure at least one file was specified
if flag.NArg() == 0 { if flag.NArg() == 0 {
fmt.Fprintf(os.Stderr, "\nError: FILE [FILE...] or './...' expected\n") // #nosec fmt.Fprintf(os.Stderr, "\nError: FILE [FILE...] or './...' expected\n") // #nosec