import os from pathlib import Path import typer from tht.config import ConfigError, load_config config_app = typer.Typer(help="Gestione configurazione") CONFIG_OPT = typer.Option( Path(os.environ.get("THT_CONFIG", "config/tht.yaml")), "--config", "-c", help="Percorso del file di configurazione.", ) @config_app.command("check") def check(config: Path = CONFIG_OPT) -> None: """Valida configurazione e variabili d'ambiente risolte.""" try: cfg = load_config(config) except ConfigError as e: typer.secho(f"ERRORE: {e}", fg=typer.colors.RED, err=True) raise typer.Exit(code=1) db = cfg.database typer.secho(f"OK: configurazione valida ({config})", fg=typer.colors.GREEN) typer.echo(f" profilo : {cfg.profile}") typer.echo(f" database : {db.user}@{db.host}:{db.port}/{db.database} schema={db.db_schema}") typer.echo(f" artifacts: {cfg.paths.artifacts} indexes: {cfg.paths.indexes}")