1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-04-29 20:23:55 +00:00

Adding nicer format script example

This commit is contained in:
Henry Fredrick Schreiner 2018-05-04 11:21:35 +02:00
parent f785046da6
commit f7d51f6a76

View File

@ -9,13 +9,15 @@ format_file() {
file="${1}" file="${1}"
case "$file" in case "$file" in
*.hpp | *.cpp | .c | *.cc | *.cu | *.h ) *.hpp | *.cpp | .c | *.cc | *.cu | *.h )
if [ -f "${1}" ] ; then
clang-format -i -style=file -sort-includes "${1}" clang-format -i -style=file -sort-includes "${1}"
if git diff-files --quiet -- "${1}" ; then if git diff-files --quiet -- "${1}" ; then
echo "Already formatted: ${1}" echo "Already nicely formatted: ${1}"
else else
git add "${1}" git add "${1}"
echo "Reformatting file: ${1}" echo "Reformatting file: ${1}"
fi; fi
fi
;; ;;
*) *)
;; ;;