1
0
mirror of https://github.com/ihabunek/toot synced 2024-12-25 00:20:55 +01:00

Merge pull reuqest #360

This commit is contained in:
Ivan Habunek 2023-06-22 11:33:20 +02:00
commit 653a18facc
No known key found for this signature in database
GPG Key ID: F5F0623FF5EBCB3D
4 changed files with 21 additions and 2 deletions

View File

@ -9,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_lists, print_out, print_instance, print_account, print_acct_list, from toot.output import (print_lists, print_out, print_instance, print_account, print_acct_list,
print_search_results, print_timeline, print_notifications, print_tag_list, print_search_results, print_timeline, print_notifications, print_tag_list,
print_list_accounts) print_list_accounts, print_user_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
@ -335,6 +335,11 @@ def logout(app, user, args):
def activate(app, user, args): def activate(app, user, args):
if not args.account:
print_out("Specify one of the following user accounts to activate:\n")
print_user_list(config.get_user_list())
return
user = config.load_user(args.account, throw=True) user = config.load_user(args.account, throw=True)
config.activate_user(user) config.activate_user(user)
print_out("<green>✓ User {} active</green>".format(config.user_id(user))) print_out("<green>✓ User {} active</green>".format(config.user_id(user)))

View File

@ -120,6 +120,11 @@ def load_user(user_id, throw=False):
raise ConsoleError("User '{}' not found".format(user_id)) raise ConsoleError("User '{}' not found".format(user_id))
def get_user_list():
config = load_config()
return config['users']
def modify_config(f): def modify_config(f):
@wraps(f) @wraps(f)
def wrapper(*args, **kwargs): def wrapper(*args, **kwargs):

View File

@ -190,6 +190,10 @@ common_auth_args = [
account_arg = (["account"], { account_arg = (["account"], {
"help": "account name, e.g. 'Gargron@mastodon.social'", "help": "account name, e.g. 'Gargron@mastodon.social'",
}) })
optional_account_arg = (["account"], {
"nargs": "?",
"help": "account name, e.g. 'Gargron@mastodon.social'",
})
instance_arg = (["-i", "--instance"], { instance_arg = (["-i", "--instance"], {
"type": str, "type": str,
@ -293,7 +297,7 @@ AUTH_COMMANDS = [
Command( Command(
name="activate", name="activate",
description="Switch between logged in accounts.", description="Switch between logged in accounts.",
arguments=[account_arg], arguments=[optional_account_arg],
require_auth=False, require_auth=False,
), ),
Command( Command(

View File

@ -203,6 +203,11 @@ def print_acct_list(accounts):
print_out(f"* <green>@{account['acct']}</green> {account['display_name']}") print_out(f"* <green>@{account['acct']}</green> {account['display_name']}")
def print_user_list(users):
for user in users:
print_out(f"* {user}")
def print_tag_list(tags): def print_tag_list(tags):
if tags: if tags:
for tag in tags: for tag in tags: