#!/bin/bash

# This scrips runs clang-format recursively on all files under specified
# directories. Formatting configuration is defined in .clang-format.

# Format isn't enforced. Code reviewer has to ensure that a code format is
# valid and appropriate for the project.

clang_format="clang-format"

for directory in src tests
do
    # If somebody wants to exclude a file from default formating here is a place
    # for that
    echo "formatting code under $directory/"
    find "$directory" \( -name '*.hpp' -or -name '*.cpp' \) -print0 | xargs -0 "${clang_format}" -i
done