diff --git a/example.json b/example.json index 8244110..fa6e81d 100644 --- a/example.json +++ b/example.json @@ -7,7 +7,6 @@ "UsePassword": true, "ConnectOnCreate": false, "HighlightNotifications": true, - "Debugger": false, "DistEnabled": true, "SendDistOutput": false, "Password": "s", diff --git a/help.json b/help.json index 4473d75..eb73280 100644 --- a/help.json +++ b/help.json @@ -4,6 +4,7 @@ "add": "add [
] [] [] []", "del": "del ", "mod": "mod [] []", + "default": "default [] []", "get": "get ", "key": "key [] [] [] []", "who": "who ", diff --git a/threshold b/threshold index 728b038..6dd3720 100755 --- a/threshold +++ b/threshold @@ -985,6 +985,70 @@ class Helper(object): else: incUsage("del") return + elif cmd == "default": + toUnset = False + if length == 1: + optionMap = ["Viewing defaults"] + for i in config["Default"].keys(): + optionMap.append("%s: %s" % (i, config["Default"][i])) + info("\n".join(optionMap)) + return + elif length == 2: + if not spl[1] in config["Default"].keys(): + failure("No such key: %s" % spl[1]) + return + info("%s: %s" % (spl[1], config["Default"][spl[1]])) + return + elif length == 3: + if not spl[1] in config["Default"].keys(): + failure("No such key: %s" % spl[1]) + return + + if spl[2].lower() in ["none", "nil"]: + spl[2] = None + toUnset = True + + if spl[1] in ["port", "timeout"]: + try: + int(spl[2]) + except: + failure("Value must be an integer, not %s" % spl[2]) + return + + if spl[1] == "protocol": + if not toUnset: + if not spl[2] in ["ssl", "plain"]: + failure("Protocol must be ssl or plain, not %s" % spl[2]) + return + + if spl[2] == config["Default"][spl[1]]: + failure("Value already exists: %s" % spl[2]) + return + + if spl[1] == "authtype": + if not toUnset: + if not spl[2] in ["sp", "ns"]: + failure("Authtype must be sp or ns, not %s" % spl[2]) + return + if spl[1] == "enabled": + failure("Use the ConnectOnCreate config parameter to set this") + return + if spl[1] == "autojoin": + if not toUnset: + spl[2] = spl[2].split(",") + else: + spl[2] = [] + + config["Default"][spl[1]] = spl[2] + self.saveConfig() + if toUnset: + success("Successfully unset key %s" % spl[1]) + else: + success("Successfully set key %s to %s" % (spl[1], spl[2])) + return + else: + incUsage("default") + return elif cmd == "mod": toUnset = False