"toot list" console command added

This commit is contained in:
Daniel Schwarz 2023-03-14 19:14:58 -04:00 committed by Ivan Habunek
parent 6bcd43a6ae
commit 855b2a1526
No known key found for this signature in database
GPG key ID: CDBD63C43A30BB95
4 changed files with 29 additions and 3 deletions

View file

@ -1,3 +1,4 @@
import sys
import platform
@ -8,7 +9,7 @@ from toot.auth import login_interactive, login_browser_interactive, create_app_i
from toot.exceptions import ApiError, ConsoleError
from toot.output import (print_out, print_instance, print_account, print_acct_list,
print_search_results, print_timeline, print_notifications,
print_tag_list)
print_tag_list, print_list_list)
from toot.tui.utils import parse_datetime
from toot.utils import args_get_instance, delete_tmp_status_file, editor_input, multiline_input, EOF_KEY
@ -423,6 +424,11 @@ def tags_followed(app, user, args):
print_tag_list(response)
def lists(app, user, args):
response = api.get_lists(app, user)
print_list_list(response)
def mute(app, user, args):
account = find_account(app, user, args.account)
api.mute(app, user, account['id'])

View file

@ -724,6 +724,14 @@ TAG_COMMANDS = [
),
]
LIST_COMMANDS = [
Command(
name="lists",
description="List all user lists",
arguments=[],
require_auth=True,
),
]
COMMAND_GROUPS = [
("Authentication", AUTH_COMMANDS),
("TUI", TUI_COMMANDS),
@ -732,6 +740,7 @@ COMMAND_GROUPS = [
("Status", STATUS_COMMANDS),
("Accounts", ACCOUNTS_COMMANDS),
("Hashtags", TAG_COMMANDS),
("Lists", LIST_COMMANDS),
]
COMMANDS = list(chain(*[commands for _, commands in COMMAND_GROUPS]))

View file

@ -210,6 +210,17 @@ def print_tag_list(tags):
print_out("You're not following any hashtags.")
def print_list_list(lists):
if lists:
for list_item in lists:
replies_policy = list_item['replies_policy'] if list_item['replies_policy'] else ''
print_out(f"Name: <green>\"{list_item['title']}\"</green>\t"
+ f"ID: <green>{list_item['id']}\t</green>"
+ f"Replies policy: <green>{replies_policy}</green>")
else:
print_out("You have no lists defined.")
def print_search_results(results):
accounts = results['accounts']
hashtags = results['hashtags']

View file

@ -1,7 +1,7 @@
# scroll.py
#
# Copied from the stig project by rndusr@github
# https://github.com/rndusr/stig
# https://github.com/rndusr/sti
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by