forked from DafeCpp/spring_alogorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformat.sh
More file actions
executable file
·27 lines (22 loc) · 763 Bytes
/
format.sh
File metadata and controls
executable file
·27 lines (22 loc) · 763 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
25
26
27
#!/bin/bash
# Check if clang-format is installed
if ! command -v clang-format &> /dev/null; then
echo "Error: clang-format is not installed. Please install it first."
echo "On Ubuntu/Debian: sudo apt-get install clang-format"
echo "On macOS: brew install clang-format"
exit 1
fi
# Find all C++ files in the project
echo "Searching for C++ files..."
FILES=$(find . -type f \( -name "*.cpp" -o -name "*.h" -o -name "*.hpp" \) -not -path "./build/*" -not -path "./.git/*" -not -path "./_deps/*")
if [ -z "$FILES" ]; then
echo "No C++ files found to format."
exit 0
fi
# Format each file
echo "Formatting files..."
for file in $FILES; do
echo "Formatting $file"
clang-format -i -style=file "$file"
done
echo "Formatting complete!"