From 6ddd624459adadf98756ec0446d2265691b1bc75 Mon Sep 17 00:00:00 2001 From: Michael Insel Date: Mon, 25 Feb 2019 17:02:10 +0100 Subject: [PATCH] Make password optional Since it is possible to not set a password on a Fritz!Box we can not require a password. This makes the --password option optional. refs #25 --- cmd/check_fritz/main.go | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/cmd/check_fritz/main.go b/cmd/check_fritz/main.go index 11a719d..e8fe538 100644 --- a/cmd/check_fritz/main.go +++ b/cmd/check_fritz/main.go @@ -79,27 +79,22 @@ func getVersion() string { return "check_fritz version " + version } -func checkRequiredFlags(hostname string, port string, username string, password string) bool { - if hostname == "" { +func checkRequiredFlags(aI *ArgumentInformation) bool { + if aI.Hostname == nil || *aI.Hostname == "" { fmt.Println("No hostname") return false } - if port == "" { + if aI.Port == nil || *aI.Port == "" { fmt.Println("No port") return false } - if username == "" { + if aI.Username == nil || *aI.Username == "" { fmt.Println("No username") return false } - if password == "" { - fmt.Println("No password") - return false - } - return true } @@ -153,7 +148,7 @@ func main() { aI.createIndex(cmdline.OptionValue("index")) } - if !checkRequiredFlags(*aI.Hostname, *aI.Port, *aI.Username, *aI.Password) { + if !checkRequiredFlags(&aI) { os.Exit(exitUnknown) }