diff --git a/toot/commands.py b/toot/commands.py
index 0a76590..dbb5eb6 100644
--- a/toot/commands.py
+++ b/toot/commands.py
@@ -9,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_lists, print_out, print_instance, print_account, print_acct_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.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):
+ 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)
config.activate_user(user)
print_out("✓ User {} active".format(config.user_id(user)))
diff --git a/toot/config.py b/toot/config.py
index 6404467..cff9856 100644
--- a/toot/config.py
+++ b/toot/config.py
@@ -120,6 +120,11 @@ def load_user(user_id, throw=False):
raise ConsoleError("User '{}' not found".format(user_id))
+def get_user_list():
+ config = load_config()
+ return config['users']
+
+
def modify_config(f):
@wraps(f)
def wrapper(*args, **kwargs):
diff --git a/toot/console.py b/toot/console.py
index 14433aa..da4f3ce 100644
--- a/toot/console.py
+++ b/toot/console.py
@@ -190,6 +190,10 @@ common_auth_args = [
account_arg = (["account"], {
"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"], {
"type": str,
@@ -293,7 +297,7 @@ AUTH_COMMANDS = [
Command(
name="activate",
description="Switch between logged in accounts.",
- arguments=[account_arg],
+ arguments=[optional_account_arg],
require_auth=False,
),
Command(
diff --git a/toot/output.py b/toot/output.py
index c89aca9..3414cdb 100644
--- a/toot/output.py
+++ b/toot/output.py
@@ -203,6 +203,11 @@ def print_acct_list(accounts):
print_out(f"* @{account['acct']} {account['display_name']}")
+def print_user_list(users):
+ for user in users:
+ print_out(f"* {user}")
+
+
def print_tag_list(tags):
if tags:
for tag in tags: