Le 3 radici intra-CLI, portate con rename psdwp3->tht + fix path import (session.phase -> phase). Espongono gli helper condivisi: CONFIG_OPT (config_cmd), _load_config_or_exit/ physical_path/annotations_path (schema_cmd), session_dir/load_session_or_exit (session_cmd). Drift phase fix in session_cmd (7 siti): MAX_PHASE -> wf.max_phase, PHASE_NAMES -> wf.phase_name(), SCHEMA_LINKING_PHASE -> wf.schema_linking_phase(). Le vecchie costanti non esistono piu' in tht.phase (sono metodi su Workflow dalla Onda -1/F2). Check grep-per-file applicato: trovati e fixati 4 residui (config/nsp.yaml, 2x 'nsp schema introspect', 'Sessioni PsdWp3') che il sed psdwp3->tht non tocca. Lesson del fix precedente applicata. session_cmd importa sql_cmd lazy (dentro finalize_cmd) -> non si rompe finche' sql_cmd (Onda 4) non sara' portato. Suite: 161 passed. tht --help ora mostra phase, config, schema, session.
27 lines
910 B
Python
27 lines
910 B
Python
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("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}")
|