diff --git a/src/wormhole/scripts/cmd_receive_file.py b/src/wormhole/scripts/cmd_receive_file.py index e578d31..4411fc5 100644 --- a/src/wormhole/scripts/cmd_receive_file.py +++ b/src/wormhole/scripts/cmd_receive_file.py @@ -17,7 +17,10 @@ def receive_file(so): }, }).encode("utf-8") r = Receiver(APPID, mydata) - r.set_code(r.input_code("Enter receive-file wormhole code: ")) + code = so["code"] + if not code: + code = r.input_code("Enter receive-file wormhole code: ") + r.set_code(code) try: data = json.loads(r.get_data().decode("utf-8")) diff --git a/src/wormhole/scripts/cmd_receive_text.py b/src/wormhole/scripts/cmd_receive_text.py index a1b1c29..2e589b3 100644 --- a/src/wormhole/scripts/cmd_receive_text.py +++ b/src/wormhole/scripts/cmd_receive_text.py @@ -8,7 +8,10 @@ def receive_text(so): # we're receiving data = json.dumps({"message": "ok"}).encode("utf-8") r = Receiver(APPID, data) - r.set_code(r.input_code("Enter receive-text wormhole code: ")) + code = so["code"] + if not code: + code = r.input_code("Enter receive-text wormhole code: ") + r.set_code(code) start = time.time() try: them_bytes = r.get_data() diff --git a/src/wormhole/scripts/runner.py b/src/wormhole/scripts/runner.py index 9fc6744..7143e99 100644 --- a/src/wormhole/scripts/runner.py +++ b/src/wormhole/scripts/runner.py @@ -7,7 +7,9 @@ class SendTextOptions(usage.Options): synopsis = "TEXT" class ReceiveTextOptions(usage.Options): - synopsis = "" + def parseArgs(self, code=None): + self["code"] = code + synopsis = "[CODE]" class SendFileOptions(usage.Options): def parseArgs(self, filename): @@ -15,7 +17,9 @@ class SendFileOptions(usage.Options): synopsis = "FILENAME" class ReceiveFileOptions(usage.Options): - synopsis = "" + def parseArgs(self, code=None): + self["code"] = code + synopsis = "[CODE]" class Options(usage.Options): synopsis = "\nUsage: wormhole "