From 0070bb27a16f44ba63f7c824b923ce685ee38fbd Mon Sep 17 00:00:00 2001 From: Leif Neland Date: Tue, 4 Dec 2018 09:01:18 +0100 Subject: [PATCH] Added -q for terse output, not command. Output is then only json, makes for easy parsing. --- tplink_smartplug.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tplink_smartplug.py b/tplink_smartplug.py index c1e8734..649877a 100755 --- a/tplink_smartplug.py +++ b/tplink_smartplug.py @@ -72,7 +72,7 @@ def decrypt(string): # Parse commandline arguments parser = argparse.ArgumentParser(description="TP-Link Wi-Fi Smart Plug Client v" + str(version)) parser.add_argument("-t", "--target", metavar="", required=True, help="Target hostname or IP address", type=validHostname) -parser.add_argument("-v", "--verbose", dest='verbose', action='store_true', help="Display verbose output") +parser.add_argument("-q", "--quiet", dest='quiet', action='store_true', help="Only show result") group = parser.add_mutually_exclusive_group(required=True) group.add_argument("-c", "--command", metavar="", help="Preset command to send. Choices are: "+", ".join(commands), choices=commands) group.add_argument("-j", "--json", metavar="", help="Full JSON string of command to send") @@ -99,11 +99,11 @@ try: decrypted = decrypt(data[4:]) - if args.verbose: + if args.quiet: + print decrypted + else: print "Sent: ", cmd print "Received: ", decrypted - else: - print decrypted except socket.error: quit("Cound not connect to host " + ip + ":" + str(port))