diff --git a/toot/cli/diag.py b/toot/cli/diag.py index 0cbdc23..fed0079 100644 --- a/toot/cli/diag.py +++ b/toot/cli/diag.py @@ -1,11 +1,9 @@ +from typing import Optional import click -from toot import api +from toot import api, config +from toot.entities import Data from toot.output import print_diags -from toot.cli import ( - cli, - pass_context, - Context, -) +from toot.cli import cli @cli.command() @@ -21,9 +19,12 @@ from toot.cli import ( is_flag=True, help="Print information about the curren server in diagnostic output", ) -@pass_context -def diag(ctx: Context, files: bool, server: bool): +def diag(files: bool, server: bool): """Display useful information for diagnosing problems""" + instance_dict: Optional[Data] = None + if server: + _, app = config.get_active_user_app() + if app: + instance_dict = api.get_instance(app.base_url).json() - instance_dict = api.get_instance(ctx.app.base_url).json() if server else None print_diags(instance_dict, files) diff --git a/toot/output.py b/toot/output.py index 1fae12e..a19bf89 100644 --- a/toot/output.py +++ b/toot/output.py @@ -4,7 +4,7 @@ import shutil import textwrap import typing as t -from toot.entities import Account, Instance, Notification, Poll, Status, List +from toot.entities import Account, Data, Instance, Notification, Poll, Status, List from toot.utils import get_text, html_to_paragraphs from toot.wcstring import wc_wrap from wcwidth import wcswidth @@ -314,7 +314,7 @@ def format_account_name(account: Account) -> str: return acct -def print_diags(instance_dict: t.Dict, include_files: bool): +def print_diags(instance_dict: t.Optional[Data], include_files: bool): from importlib.metadata import version click.echo(f'{green(f"Diagnostic Information")}')