"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 sys
import platform 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.exceptions import ApiError, ConsoleError
from toot.output import (print_out, print_instance, print_account, print_acct_list, from toot.output import (print_out, print_instance, print_account, print_acct_list,
print_search_results, print_timeline, print_notifications, 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.tui.utils import parse_datetime
from toot.utils import args_get_instance, delete_tmp_status_file, editor_input, multiline_input, EOF_KEY 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) print_tag_list(response)
def lists(app, user, args):
response = api.get_lists(app, user)
print_list_list(response)
def mute(app, user, args): def mute(app, user, args):
account = find_account(app, user, args.account) account = find_account(app, user, args.account)
api.mute(app, user, account['id']) 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 = [ COMMAND_GROUPS = [
("Authentication", AUTH_COMMANDS), ("Authentication", AUTH_COMMANDS),
("TUI", TUI_COMMANDS), ("TUI", TUI_COMMANDS),
@ -732,6 +740,7 @@ COMMAND_GROUPS = [
("Status", STATUS_COMMANDS), ("Status", STATUS_COMMANDS),
("Accounts", ACCOUNTS_COMMANDS), ("Accounts", ACCOUNTS_COMMANDS),
("Hashtags", TAG_COMMANDS), ("Hashtags", TAG_COMMANDS),
("Lists", LIST_COMMANDS),
] ]
COMMANDS = list(chain(*[commands for _, commands in COMMAND_GROUPS])) 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.") 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): def print_search_results(results):
accounts = results['accounts'] accounts = results['accounts']
hashtags = results['hashtags'] hashtags = results['hashtags']

View File

@ -1,7 +1,7 @@
# scroll.py # scroll.py
# #
# Copied from the stig project by rndusr@github # 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 # 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 # it under the terms of the GNU General Public License as published by
@ -423,4 +423,4 @@ class ScrollBar(urwid.WidgetDecoration):
ow.set_scrollpos(pos + 1) ow.set_scrollpos(pos + 1)
return True return True
return False return False