#!/usr/bin/env bash set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="${SCRIPT_DIR}/.." SRC_DIR="${PROJECT_ROOT}/src" if ! command -v clang-format >/dev/null 2>&1; then echo "error: clang-format is not installed or not in PATH" >&2 exit 1 fi if [ ! -d "${SRC_DIR}" ]; then echo "warning: src directory not found; nothing to format" >&2 exit 0 fi find "${SRC_DIR}" -name '*.cpp' -o -name '*.hpp' -o -name '*.h' | while read -r file; do clang-format -i "$file" echo "formatted $file" done