receive-text/file: accept CODE in argv

This commit is contained in:
Brian Warner 2015-03-15 23:26:06 -07:00
parent 12414fd8be
commit cef9abcdd7
3 changed files with 14 additions and 4 deletions

View File

@ -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"))

View File

@ -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()

View File

@ -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 <command>"