From 3de561a0609c34e972e7f3a31c47c0f5108347a9 Mon Sep 17 00:00:00 2001 From: Ivan Habunek Date: Sat, 18 Nov 2023 15:27:18 +0100 Subject: [PATCH] Add --json argument to whois command --- toot/commands.py | 10 +++++++--- toot/console.py | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/toot/commands.py b/toot/commands.py index 808c484..e16d8f1 100644 --- a/toot/commands.py +++ b/toot/commands.py @@ -1,4 +1,4 @@ - +import json import sys import platform @@ -526,8 +526,12 @@ def whoami(app, user, args): def whois(app, user, args): account = api.find_account(app, user, args.account) - account = from_dict(Account, account) - print_account(account) + # Here it's not possible to avoid parsing json since it's needed to find the account. + if args.json: + print(json.dumps(account)) + else: + account = from_dict(Account, account) + print_account(account) def instance(app, user, args): diff --git a/toot/console.py b/toot/console.py index 9733d09..9515d68 100644 --- a/toot/console.py +++ b/toot/console.py @@ -404,6 +404,7 @@ READ_COMMANDS = [ (["account"], { "help": "account name or numeric ID" }), + json_arg, ], require_auth=True, ),