-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathformat.sh
More file actions
executable file
·25 lines (20 loc) · 622 Bytes
/
format.sh
File metadata and controls
executable file
·25 lines (20 loc) · 622 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env bash
# format.sh - format files with clang-format
set -euo pipefail
# Path to clang-format (adjust if needed)
CLANG_FORMAT="${CLANG_FORMAT:-clang-format}"
# If a file is passed as argument, format that file
if [[ $# -gt 0 ]]; then
for file in "$@"; do
echo "Formatting $file"
"$CLANG_FORMAT" -i --style=file "$file"
done
else
# No arguments: format all tracked source files
files=$(git ls-files '*.cpp' '*.hpp' '*.h' '*.c' '*.cc' '*.hh')
for file in $files; do
echo "Formatting $file"
"$CLANG_FORMAT" -i --style=file "$file"
done
fi
echo "Done!"