From ec51adb713b33edc923fc48411fa785d8ca5012d Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Wed, 11 Nov 2015 17:27:26 -0800 Subject: [PATCH] add 'wormhole send --text -' to read message from stdin --- NEWS.md | 1 + src/wormhole/scripts/cmd_send.py | 3 +++ src/wormhole/scripts/runner.py | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 85b97dd..7d16de1 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 receivers still display the traceback, since they don't check the welcome message before using a missing API. +* Fix `wormhole send --text -` to read the text message from stdin. ## Release 0.5.0 (07-Oct-2015) diff --git a/src/wormhole/scripts/cmd_send.py b/src/wormhole/scripts/cmd_send.py index 18f8e4a..6f10c0f 100644 --- a/src/wormhole/scripts/cmd_send.py +++ b/src/wormhole/scripts/cmd_send.py @@ -13,6 +13,9 @@ def send(args): assert isinstance(args.relay_url, type(u"")) text = args.text + if text == "-": + print("Reading text message from stdin..") + text = sys.stdin.read() if not text and not args.what: text = six.moves.input("Text to send: ") diff --git a/src/wormhole/scripts/runner.py b/src/wormhole/scripts/runner.py index a95b72e..f32edef 100644 --- a/src/wormhole/scripts/runner.py +++ b/src/wormhole/scripts/runner.py @@ -68,7 +68,7 @@ p = subparsers.add_parser("send", description="Send text message or file", usage="wormhole send [FILENAME]") 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", type=type(u"")) p.add_argument("-0", dest="zeromode", action="store_true",