MCPcopy Create free account
hub / github.com/ClickHouse/ai-sdk-cpp / run_command

Function run_command

scripts/build.py:44–59  ·  view source on GitHub ↗

Run a command and handle errors with rich output.

(cmd: list[str], cwd: Optional[Path] = None, check: bool = True)

Source from the content-addressed store, hash-verified

42
43
44def run_command(cmd: list[str], cwd: Optional[Path] = None, check: bool = True) -> subprocess.CompletedProcess:
45 """Run a command and handle errors with rich output."""
46 console.print(f"[dim]Running:[/dim] [cyan]{' '.join(cmd)}[/cyan]")
47
48 try:
49 result = subprocess.run(cmd, cwd=cwd, check=check, capture_output=True, text=True)
50 if result.stdout.strip():
51 console.print(f"[dim]{result.stdout.strip()}[/dim]")
52 return result
53 except subprocess.CalledProcessError as e:
54 console.print(f"[red]Error running command:[/red] {e}")
55 if e.stderr:
56 console.print(f"[red]Error output:[/red] {e.stderr}")
57 if e.stdout:
58 console.print(f"[yellow]Output:[/yellow] {e.stdout}")
59 sys.exit(1)
60
61
62

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected