clang-format-wheel icon indicating copy to clipboard operation
clang-format-wheel copied to clipboard

Make method for getting the executable public

Open Lauszus opened this issue 5 months ago • 0 comments

This is useful if one wants to call the executable in Python

For instance I use this to format my code like so:

def check_call_clang_format(cmd: str) -> None:
    clang_format_exe = clang_format.get_executable("clang-format")
    clang_format_sw_styles_path = importlib.resources.files("mylib.utils").joinpath(".clang-format")
    clang_format_cmd = [
        clang_format_exe,
        f"--style=file:{clang_format_sw_styles_path}",
        cmd,
    ]
    subprocess.check_call(
        " ".join(clang_format_cmd),
        shell=True,
    )

Lauszus avatar Sep 11 '24 11:09 Lauszus