parent
62385ac9fa
commit
14a580bc19
3 changed files with 22 additions and 1 deletions
|
@ -5,6 +5,7 @@ Changelog
|
|||
|
||||
* Enable interaction with instances using http instead of https (#56)
|
||||
* Enable proxy usage via environment variables (#47)
|
||||
* Make `toot post` prompt for input if no text is given (#82)
|
||||
|
||||
**0.19.0 (2018-06-27)**
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ from toot import api, config
|
|||
from toot.auth import login_interactive, login_browser_interactive, create_app_interactive
|
||||
from toot.exceptions import ConsoleError, NotFoundError
|
||||
from toot.output import print_out, print_instance, print_account, print_search_results, print_timeline
|
||||
from toot.utils import assert_domain_exists
|
||||
from toot.utils import assert_domain_exists, multiline_input, EOF_KEY
|
||||
|
||||
|
||||
def timeline(app, user, args):
|
||||
|
@ -56,6 +56,10 @@ def post(app, user, args):
|
|||
if media and not args.text:
|
||||
args.text = media['text_url']
|
||||
|
||||
if not args.text:
|
||||
print_out("Write or paste your toot. Press <yellow>{}</yellow> to post it.".format(EOF_KEY))
|
||||
args.text = multiline_input()
|
||||
|
||||
if not args.text:
|
||||
raise ConsoleError("You must specify either text or media to post.")
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import re
|
||||
import socket
|
||||
import unicodedata
|
||||
|
@ -68,3 +69,18 @@ def trunc(text, length):
|
|||
return text
|
||||
|
||||
return text[:length - 1] + '…'
|
||||
|
||||
|
||||
EOF_KEY = "Ctrl-Z" if os.name == 'nt' else "Ctrl-D"
|
||||
|
||||
|
||||
def multiline_input():
|
||||
"""Lets user input multiple lines of text, terminated by EOF."""
|
||||
lines = []
|
||||
while True:
|
||||
try:
|
||||
lines.append(input())
|
||||
except EOFError:
|
||||
break
|
||||
|
||||
return "\n".join(lines).strip()
|
||||
|
|
Loading…
Reference in a new issue