Source code for gitlab_overviewer.cli.diag

 1"""Diagnostic utilities for settings and configuration.
 2
 3Implements :any:`/specs/spec_settings` §2-3, covering:
 4
 5* Settings validation (§2)
 6* Diagnostic output (§3)
 7"""
 8
 9import subprocess
10import sys
11from pathlib import Path
12
13
[docs] 14def run_script(script_path: str | Path) -> bool: 15 """Run a diagnostic script and return True if successful.""" 16 try: 17 subprocess.run( 18 ["poetry", "run", "python", str(script_path)], 19 check=True, 20 capture_output=True, 21 text=True, 22 ) 23 print(f"✓ Successfully ran {script_path}") 24 return True 25 except subprocess.CalledProcessError as e: 26 print(f"✗ Error running {script_path}:", file=sys.stderr) 27 print(e.stderr, file=sys.stderr) 28 return False
29 30
[docs] 31def main() -> int: 32 """Run all diagnostic scripts in sequence.""" 33 scripts = [ 34 "tmp/diag_api.py", 35 "tmp/diag_collector.py", 36 "tmp/diag_mapper.py", 37 ] 38 39 print("Running diagnostic scripts...") 40 success = True 41 for script in scripts: 42 if not run_script(script): 43 success = False 44 break 45 46 if success: 47 print("\nAll diagnostic scripts completed successfully!") 48 return 0 49 else: 50 print("\nDiagnostic pipeline failed.", file=sys.stderr) 51 return 1
52 53 54if __name__ == "__main__": 55 sys.exit(main())