diff --git a/src/wormhole/scripts/cmd_send.py b/src/wormhole/scripts/cmd_send.py index 1b5aa0e..a35aa9e 100644 --- a/src/wormhole/scripts/cmd_send.py +++ b/src/wormhole/scripts/cmd_send.py @@ -11,7 +11,20 @@ def send(args): from ..blocking.transit import TransitSender from .progress import start_progress, update_progress, finish_progress - if os.path.isfile(args.what): + text = args.text + if not text and not args.what: + text = six.moves.input("Text to send: ") + + if text is not None: + sending_message = True + print("Sending text message (%d bytes)" % len(text)) + phase1 = { + "message": text, + } + else: + if not os.path.isfile(args.what): + print("Cannot send: no file named '%s'" % args.what) + return 1 # we're sending a file sending_message = False filesize = os.stat(args.what).st_size @@ -28,12 +41,6 @@ def send(args): "relay_connection_hints": transit_sender.get_relay_hints(), }, } - else: - sending_message = True - print("Sending text message (%d bytes)" % len(args.what)) - phase1 = { - "message": args.what, - } w = Wormhole(APPID, args.relay_url) if args.zeromode: diff --git a/src/wormhole/scripts/runner.py b/src/wormhole/scripts/runner.py index 77b8df0..6619248 100644 --- a/src/wormhole/scripts/runner.py +++ b/src/wormhole/scripts/runner.py @@ -65,12 +65,14 @@ sp_restart.set_defaults(func=cmd_server.restart_server) # CLI: send p = subparsers.add_parser("send", description="Send text message or file", - usage="wormhole send TEXT|FILENAME") + usage="wormhole send [FILENAME]") +p.add_argument("--text", metavar="MESSAGE", + help="text message to send, instead of a file") p.add_argument("--code", metavar="CODE", help="human-generated code phrase") p.add_argument("-0", dest="zeromode", action="store_true", help="enable no-code anything-goes mode") -p.add_argument("what", metavar="TEXT|FILENAME", - help="the message to send (a string), or a filename") +p.add_argument("what", nargs="?", default=None, metavar="[FILENAME]", + help="the file to send") p.set_defaults(func=cmd_send.send) # CLI: receive @@ -82,7 +84,7 @@ p.add_argument("-0", dest="zeromode", action="store_true", p.add_argument("-t", "--only-text", dest="only_text", action="store_true", help="refuse file transfers, only accept text transfers") p.add_argument("--accept-file", dest="accept_file", action="store_true", - help="accept file transfer with prompting") + help="accept file transfer with asking for confirmation") p.add_argument("-o", "--output-file", default=None, metavar="FILENAME", help=dedent("""\ The file to create, overriding the filename suggested by the