Initial commit
This commit is contained in:
31
format.sh
Normal file
31
format.sh
Normal file
@@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Variable that will hold the name of the clang-format command
|
||||
FMT="clang-format"
|
||||
|
||||
# Function to format files
|
||||
format() {
|
||||
for f in $(find "$1" \( -name '*.h' -or -name '*.m' -or -name '*.mm' -or -name '*.c' -or -name '*.cpp' \)); do
|
||||
# Skip *_generated.h files
|
||||
if [[ "$f" == *_generated.h ]]; then
|
||||
continue
|
||||
fi
|
||||
echo "format ${f}"
|
||||
${FMT} -i "${f}"
|
||||
done
|
||||
echo "~~~ $1 Done ~~~"
|
||||
}
|
||||
|
||||
# Check if argument is provided
|
||||
if [ -z "$1" ]; then
|
||||
echo "Please provide a directory as an argument."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if directory exists
|
||||
if [ ! -d "$1" ]; then
|
||||
echo "$1 is not a valid directory."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
format "$1"
|
||||
Reference in New Issue
Block a user