1
0
mirror of https://github.com/ihabunek/toot synced 2024-12-22 23:08:17 +01:00

Added toot diag -s flag; if specified, includes server info

This commit is contained in:
Daniel Schwarz 2024-08-04 23:37:40 -04:00
parent 62fa59cc06
commit 1883042344
2 changed files with 21 additions and 3 deletions

View File

@ -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)

View File

@ -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: