kopia lustrzana https://github.com/ihabunek/toot
rodzic
62385ac9fa
commit
14a580bc19
|
@ -5,6 +5,7 @@ Changelog
|
||||||
|
|
||||||
* Enable interaction with instances using http instead of https (#56)
|
* Enable interaction with instances using http instead of https (#56)
|
||||||
* Enable proxy usage via environment variables (#47)
|
* 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)**
|
**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.auth import login_interactive, login_browser_interactive, create_app_interactive
|
||||||
from toot.exceptions import ConsoleError, NotFoundError
|
from toot.exceptions import ConsoleError, NotFoundError
|
||||||
from toot.output import print_out, print_instance, print_account, print_search_results, print_timeline
|
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):
|
def timeline(app, user, args):
|
||||||
|
@ -56,6 +56,10 @@ def post(app, user, args):
|
||||||
if media and not args.text:
|
if media and not args.text:
|
||||||
args.text = media['text_url']
|
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:
|
if not args.text:
|
||||||
raise ConsoleError("You must specify either text or media to post.")
|
raise ConsoleError("You must specify either text or media to post.")
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
import socket
|
import socket
|
||||||
import unicodedata
|
import unicodedata
|
||||||
|
@ -68,3 +69,18 @@ def trunc(text, length):
|
||||||
return text
|
return text
|
||||||
|
|
||||||
return text[:length - 1] + '…'
|
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()
|
||||||
|
|
Ładowanie…
Reference in New Issue