Add --language option to post command

Used to override language detection.
pull/113/head
Ivan Habunek 2019-07-30 16:13:29 +02:00
rodzic e5bba7e9b3
commit a7e4f9d888
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: CDBD63C43A30BB95
4 zmienionych plików z 23 dodań i 4 usunięć

Wyświetl plik

@ -5,6 +5,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`
**0.21.0 (2019-02-15)**

Wyświetl plik

@ -92,7 +92,8 @@ def post_status(
media_ids=None,
sensitive=False,
spoiler_text=None,
in_reply_to_id=None
in_reply_to_id=None,
language=None,
):
"""
Posts a new status.
@ -110,6 +111,7 @@ def post_status(
'sensitive': str_bool(sensitive),
'spoiler_text': spoiler_text,
'in_reply_to_id': in_reply_to_id,
'language': language,
}, headers=headers).json()

Wyświetl plik

@ -100,6 +100,7 @@ def post(app, user, args):
sensitive=args.sensitive,
spoiler_text=args.spoiler_text,
in_reply_to_id=args.reply_to,
language=args.language,
)
print_out("Toot posted: <green>{}</green>".format(response.get('url')))

Wyświetl plik

@ -13,8 +13,19 @@ from toot.output import print_out, print_err
VISIBILITY_CHOICES = ['public', 'unlisted', 'private', 'direct']
def language(value):
"""Validates the language parameter"""
if len(value) != 3:
raise ArgumentTypeError(
"Invalid language specified: '{}'. Expected a 3 letter "
"abbreviation according to ISO 639-2 standard.".format(value)
)
return value
def visibility(value):
"""Validates the visibilty parameter"""
"""Validates the visibility parameter"""
if value not in VISIBILITY_CHOICES:
raise ValueError("Invalid visibility value")
@ -275,11 +286,15 @@ POST_COMMANDS = [
}),
(["-p", "--spoiler-text"], {
"type": str,
"help": 'text to be shown as a warning before the actual content',
"help": "text to be shown as a warning before the actual content",
}),
(["-r", "--reply-to"], {
"type": int,
"help": 'local ID of the status you want to reply to',
"help": "local ID of the status you want to reply to",
}),
(["-l", "--language"], {
"type": language,
"help": "ISO 639-2 language code of the toot, to skip automatic detection",
}),
],
require_auth=True,