mirror of
https://github.com/ihabunek/toot.git
synced 2024-11-03 04:17:21 -05:00
Merge pull reuqest #360
This commit is contained in:
commit
653a18facc
@ -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)))
|
||||||
|
@ -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):
|
||||||
|
@ -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(
|
||||||
|
@ -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:
|
||||||
|
Loading…
Reference in New Issue
Block a user