1
0
mirror of https://github.com/ihabunek/toot synced 2025-01-11 00:53:49 +01:00
Toot-Mastodon-CLI-TUI-clien.../toot/cli/diag.py

32 lines
840 B
Python
Raw Normal View History

2024-08-12 08:57:59 +02:00
from typing import Optional
import click
2024-08-12 08:57:59 +02:00
from toot import api, config
2024-09-29 09:08:06 +02:00
from toot.entities import Data, Instance, from_dict
from toot.output import print_diags
2024-08-12 08:57:59 +02:00
from toot.cli import cli
@cli.command()
@click.option(
"-f",
"--files",
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",
)
2024-08-12 08:57:59 +02:00
def diag(files: bool, server: bool):
"""Display useful information for diagnosing problems"""
2024-09-29 09:08:06 +02:00
instance: Optional[Instance] = None
2024-08-12 08:57:59 +02:00
if server:
_, app = config.get_active_user_app()
if app:
2024-09-29 09:08:06 +02:00
response = api.get_instance(app.base_url)
instance = from_dict(Instance, response.json())
2024-09-29 09:08:06 +02:00
print_diags(instance, files)