summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2b8904e)
raw | patch | inline | side by side (parent: 2b8904e)
author | Florian Forster <octo@collectd.org> | |
Mon, 23 Oct 2017 15:03:10 +0000 (17:03 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Mon, 23 Oct 2017 15:03:10 +0000 (17:03 +0200) |
contrib/format.sh | [new file with mode: 0755] | patch | blob |
diff --git a/contrib/format.sh b/contrib/format.sh
--- /dev/null
+++ b/contrib/format.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+# This script sends files to a web service using POST requests and reads back
+# the correctly formatted source files. This allows to apply clang-format
+# without having to install the tool locally.
+
+if test $# -lt 1; then
+ echo "Usage $0 <file> [<file> ...]"
+ exit 1
+fi
+
+for i in "$@"; do
+ d="$(dirname "${i}")"
+ o="$(tempfile -d "${d}" -m 0644)"
+
+ curl --silent --data-binary "@-" https://clang-format.appspot.com/ <"${i}" >"${o}"
+ if test $? -eq 0; then
+ cat "${o}" >"${i}"
+ fi
+ rm -f "${o}"
+done