From 05324f3381e7ac47efd6d39f2d93f9ffc063de62 Mon Sep 17 00:00:00 2001 From: Andrey Meshkov Date: Thu, 27 Aug 2020 14:50:54 +0300 Subject: [PATCH] add -v and --version --- main.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 772ec62..1ed093a 100644 --- a/main.go +++ b/main.go @@ -24,15 +24,19 @@ func main() { if !machineReadable { os.Stdout.WriteString(fmt.Sprintf("dnslookup %s\n", VersionString)) + + if len(os.Args) == 2 && (os.Args[1] == "-v" || os.Args[1] == "--version") { + os.Exit(0) + } } if insecureSkipVerify { os.Stdout.WriteString("TLS verification has been disabled\n") } - if len(os.Args) == 1 && os.Args[0] == "-h" { + if len(os.Args) == 2 && (os.Args[1] == "-h" || os.Args[1] == "--help") { usage() - os.Exit(1) + os.Exit(0) } if len(os.Args) != 3 && len(os.Args) != 4 && len(os.Args) != 5 {