feat: add option not

This commit is contained in:
Adrien Waksberg 2019-06-27 21:08:08 +02:00
parent c6aaebc509
commit 7ec7bf8d81

View file

@ -16,6 +16,7 @@ var (
IP = flag.String("ip", "", "")
FILE = flag.String("file", "", "")
COMMAND = flag.String("command", "", "command to execute")
NOT = flag.Bool("not", false, "execute the command if the ip or the file isn't present")
)
// Critical print a message and exit with code 2
@ -86,15 +87,23 @@ func ipExist(ip string) bool {
}
func main() {
var isMaster bool
var execute bool
if *FILE != "" {
isMaster = fileExist(*FILE)
execute = fileExist(*FILE)
} else {
isMaster = ipExist(*IP)
execute = ipExist(*IP)
}
if isMaster == false {
if *NOT {
if execute {
execute = false
} else {
execute = true
}
}
if execute {
Ok("I have nothing to do, i going to sleep")
}