summaryrefslogtreecommitdiff
path: root/tomlplusplus/tools/clang_format.bat
diff options
context:
space:
mode:
Diffstat (limited to 'tomlplusplus/tools/clang_format.bat')
-rw-r--r--tomlplusplus/tools/clang_format.bat41
1 files changed, 41 insertions, 0 deletions
diff --git a/tomlplusplus/tools/clang_format.bat b/tomlplusplus/tools/clang_format.bat
new file mode 100644
index 0000000000..7f2a139b7a
--- /dev/null
+++ b/tomlplusplus/tools/clang_format.bat
@@ -0,0 +1,41 @@
+@ECHO off
+SETLOCAL enableextensions enabledelayedexpansion
+PUSHD .
+CD /d "%~dp0\.."
+
+REM --------------------------------------------------------------------------------------
+REM Runs clang format on all the C++ files in the project
+REM --------------------------------------------------------------------------------------
+
+WHERE /Q clang-format
+IF %ERRORLEVEL% NEQ 0 (
+ ECHO Could not find clang-format
+ PAUSE
+ POPD
+ ENDLOCAL
+ EXIT /B %ERRORLEVEL%
+)
+
+CALL :RunClangFormatOnDirectories ^
+ include\toml++ ^
+ include\toml++\impl ^
+ tests ^
+ examples
+
+POPD
+@ENDLOCAL
+EXIT /B 0
+
+:RunClangFormatOnDirectories
+(
+ FOR %%i IN (%*) DO (
+ IF EXIST "%%~i" (
+ ECHO Formatting files in "%%~i"
+ clang-format --style=file -i "%%~i\*.cpp" >nul 2>&1
+ clang-format --style=file -i "%%~i\*.h" >nul 2>&1
+ clang-format --style=file -i "%%~i\*.hpp" >nul 2>&1
+ clang-format --style=file -i "%%~i\*.inl" >nul 2>&1
+ )
+ )
+ EXIT /B
+)