add 'wormhole send --text -' to read message from stdin

This commit is contained in:
Brian Warner 2015-11-11 17:27:26 -08:00
parent b83062701d
commit ec51adb713
3 changed files with 5 additions and 1 deletions

View File

@ -7,6 +7,7 @@ User-visible changes in "magic-wormhole":
current (0.5.0) server, instead of an ugly stack trace. Unfortunately 0.4.0 current (0.5.0) server, instead of an ugly stack trace. Unfortunately 0.4.0
receivers still display the traceback, since they don't check the welcome receivers still display the traceback, since they don't check the welcome
message before using a missing API. message before using a missing API.
* Fix `wormhole send --text -` to read the text message from stdin.
## Release 0.5.0 (07-Oct-2015) ## Release 0.5.0 (07-Oct-2015)

View File

@ -13,6 +13,9 @@ def send(args):
assert isinstance(args.relay_url, type(u"")) assert isinstance(args.relay_url, type(u""))
text = args.text text = args.text
if text == "-":
print("Reading text message from stdin..")
text = sys.stdin.read()
if not text and not args.what: if not text and not args.what:
text = six.moves.input("Text to send: ") text = six.moves.input("Text to send: ")

View File

@ -68,7 +68,7 @@ p = subparsers.add_parser("send",
description="Send text message or file", description="Send text message or file",
usage="wormhole send [FILENAME]") usage="wormhole send [FILENAME]")
p.add_argument("--text", metavar="MESSAGE", p.add_argument("--text", metavar="MESSAGE",
help="text message to send, instead of a file") help="text message to send, instead of a file. Use '-' to read from stdin.")
p.add_argument("--code", metavar="CODE", help="human-generated code phrase", p.add_argument("--code", metavar="CODE", help="human-generated code phrase",
type=type(u"")) type=type(u""))
p.add_argument("-0", dest="zeromode", action="store_true", p.add_argument("-0", dest="zeromode", action="store_true",