summaryrefslogtreecommitdiffhomepage
path: root/format.sh
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-03-24 07:33:45 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2025-03-24 07:33:45 +0100
commitff0d2f98126cee6639ca4f8f859b4f5efae571d9 (patch)
treee39e4232f80511beef217df642b6152e7f339c08 /format.sh
parent28f1d62affa05a33604609677b50f6609ddc2746 (diff)
meta(proj): rename run_format to format.sh
Diffstat (limited to 'format.sh')
-rwxr-xr-xformat.sh16
1 files changed, 16 insertions, 0 deletions
diff --git a/format.sh b/format.sh
new file mode 100755
index 0000000..cd22f98
--- /dev/null
+++ b/format.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+THIS_PATH="$(realpath "$0")"
+THIS_DIR="$(dirname "$THIS_PATH")"
+
+# Find all files in THIS_DIR which end in .ino, .cpp, etc., as specified
+# in the regular expression just below
+FILE_LIST="$(find "$THIS_DIR" | grep -E ".*(\.ino|\.cpp|\.c|\.h|\.hpp|\.hxx|\.cxx|\.cc|\.hh)$")"
+
+echo -e "Files found to format = \n\"\"\"\n$FILE_LIST\n\"\"\""
+
+# Format each file.
+# - NB: do NOT put quotes around `$FILE_LIST` below or else the `clang-format` command will
+# mistakenly see the entire blob of newline-separated file names as a SINGLE file name instead
+# of as a new-line separated list of *many* file names!
+clang-format --verbose -i --style=file $FILE_LIST