Fix: autodetect proper directories to format

This commit is contained in:
Emmanuel Engelhart 2022-09-29 20:35:51 +02:00
parent de7fa771fc
commit f61fc07121
No known key found for this signature in database
GPG Key ID: 120B30D020B553D3
1 changed files with 5 additions and 10 deletions

View File

@ -1,17 +1,12 @@
#!/usr/bin/bash
# Print usage() if no argument given
if [ $# -eq 0 ]
then
echo "./format_code.sh MY_DIR_TO_FORMAT"
exit 1
fi
# Retrieve directory to parse
DIR=$1
# Compute 'src' path
SCRIPT_DIR=$(dirname "$0")
REPO_DIR=$(readlink -f "$SCRIPT_DIR"/..)
DIRS="$REPO_DIR/src $REPO_DIR/include"
# Apply formating to all *.cpp and *.h files
for FILE in `find "$DIR" -name '*.h' -o -name '*.cpp'`
for FILE in $(find $DIRS -name '*.h' -o -name '*.cpp')
do
echo $FILE
clang-format -i -style=file "$FILE"