INNER CODE UNIT · Python
format_file
ClickHouse/ai-sdk-cpp · scripts/format.py:57
def format_file(file: Path) -> None:
"""Format a file in place."""
subprocess.run(
["clang-format", "-i", str(file)],
check=True
)
@click.command()
@click.option("--check", is_flag=True, help="Check formatting without modifying files")
def main(check: bool):
"""Format all C++ source files using clang-format."""
# Check if clang-format is installed
if not shutil.which("clang-format"):
console.print("[red]Error: clang-format is not installed.[/red]")
console.print("Install it with: brew install clang-format (macOS) or apt-get install clang-format (Ubuntu)")
sys.exit(1)