Allow posting media without text - toot - Unnamed repository; edit this file 'description' to name the repository.
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
(DIR) commit fde6bd61258ba22ea52c10a2412aabb4c3ff79ee
(DIR) parent 92d4dc745ad51a9cdd8eb70e3e508f2d1ab57afc
(HTM) Author: Ivan Habunek <ivan@habunek.com>
Date: Sat, 30 Dec 2017 16:42:52 +0100
Allow posting media without text
issue #24
Diffstat:
toot/commands.py | 7 +++++++
toot/console.py | 1 +
2 files changed, 8 insertions(+), 0 deletions(-)
---
(DIR) diff --git a/toot/commands.py b/toot/commands.py
@@ -74,8 +74,15 @@ def post(app, user, args):
media = _do_upload(app, user, args.media)
media_ids = [media['id']]
else:
+ media = None
media_ids = None
+ if media and not args.text:
+ args.text = media['text_url']
+
+ if not args.text:
+ raise ConsoleError("You must specify either text or media to post.")
+
response = api.post_status(app, user, args.text, args.visibility, media_ids)
print_out("Toot posted: <green>{}</green>".format(response.get('url')))
(DIR) diff --git a/toot/console.py b/toot/console.py
@@ -144,6 +144,7 @@ POST_COMMANDS = [
arguments=[
(["text"], {
"help": "The status text to post.",
+ "nargs": "?",
}),
(["-m", "--media"], {
"type": FileType('rb'),