diff --git a/toot/cli/diag.py b/toot/cli/diag.py index 6ec4973..0cbdc23 100644 --- a/toot/cli/diag.py +++ b/toot/cli/diag.py @@ -1,4 +1,5 @@ import click +from toot import api from toot.output import print_diags from toot.cli import ( cli, @@ -14,8 +15,15 @@ from toot.cli import ( is_flag=True, help="Print contents of the config and settings files in diagnostic output", ) +@click.option( + "-s", + "--server", + is_flag=True, + help="Print information about the curren server in diagnostic output", +) @pass_context -def diag(ctx: Context, files: bool): +def diag(ctx: Context, files: bool, server: bool): """Display useful information for diagnosing problems""" - print_diags(files) + 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 df7c868..1fae12e 100644 --- a/toot/output.py +++ b/toot/output.py @@ -314,7 +314,7 @@ def format_account_name(account: Account) -> str: return acct -def print_diags(include_files: bool): +def print_diags(instance_dict: t.Dict, include_files: bool): from importlib.metadata import version click.echo(f'{green(f"Diagnostic Information")}') @@ -356,6 +356,16 @@ def print_diags(include_files: bool): click.echo(f'{green(f"Settings file path:")} {settings.get_settings_path()}') click.echo(f'{green(f"Config file path:")} {config.get_config_file_path()}') + if instance_dict: + try: + click.echo(f'{green(f"Server URI:")} {instance_dict["uri"]}') + except: # noqa E722 + pass + try: + click.echo(f'{green(f"Server version:")} {instance_dict["version"]}') + except: # noqa E722 + pass + if include_files: click.echo(f'{green(f"Settings file contents:")}') try: