How to call clang-format over a cpp project folder?

后端 未结 9 2137
眼角桃花
眼角桃花 2021-01-29 21:43

Is there a way to call something like clang-format --style=Webkit for an entire cpp project folder, rather than running it separately for each file?

I am us

9条回答
  •  一向
    一向 (楼主)
    2021-01-29 22:02

    For the Windows users: If you have Powershell 3.0 support, you can do:

    Get-ChildItem -Path . -Directory -Recurse |
        foreach {
            cd $_.FullName
            &clang-format -i -style=WebKit *.cpp
        }
    

    Note1: Use pushd . and popd if you want to have the same current directory before and after the script

    Note2: The script operates in the current working directory

    Note3: This can probably be written in a single line if that was really important to you

提交回复
热议问题