diff --git a/CHANGELOG.md b/CHANGELOG.md index a6e9e87..5a0d117 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Changelog * Add `toot notifications` to show notifications (thanks @dlax) * Add posting and replying to curses interface (thanks @Skehmatics) * Add `--language` option to `toot post` +* Enable attaching upto 4 files via `--media` option on `toot post` **0.21.0 (2019-02-15)** diff --git a/toot/commands.py b/toot/commands.py index 139ce8f..3fee651 100644 --- a/toot/commands.py +++ b/toot/commands.py @@ -76,15 +76,18 @@ def curses(app, user, args): def post(app, user, args): + if args.media and len(args.media) > 4: + raise ConsoleError("Cannot attach more than 4 files.") + if args.media: - media = _do_upload(app, user, args.media) - media_ids = [media['id']] + media = [_do_upload(app, user, file) for file in args.media] + media_ids = [m["id"] for m in media] else: media = None media_ids = None if media and not args.text: - args.text = media['text_url'] + args.text = "\n".join(m['text_url'] for m in media) if not args.text: print_out("Write or paste your toot. Press {} to post it.".format(EOF_KEY)) diff --git a/toot/console.py b/toot/console.py index ed4d31d..82c33a0 100644 --- a/toot/console.py +++ b/toot/console.py @@ -271,8 +271,10 @@ POST_COMMANDS = [ "nargs": "?", }), (["-m", "--media"], { - "type": FileType('rb'), - "help": "path to the media file to attach" + "action": "append", + "type": FileType("rb"), + "help": "path to the media file to attach (specify multiple " + "times to attach up to 4 files)" }), (["-v", "--visibility"], { "type": visibility,