From bfc77ad99487ca67729c0d90940ca5025e1994d1 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Mon, 23 Oct 2017 17:03:10 +0200 Subject: [PATCH] contrib/format.sh: Add script for formatting files using a remote clang-format. --- contrib/format.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 contrib/format.sh diff --git a/contrib/format.sh b/contrib/format.sh new file mode 100755 index 00000000..d4444cc2 --- /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 [ ...]" + 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 -- 2.11.0