mach

A work-in-progress implementation of make(1)

git clone https://git.8pit.net/mach.git

 1#!/bin/sh
 2
 3if ! command -v ormolu 1>/dev/null; then
 4	echo "error: ormolu is not installed" 1>&2
 5	exit 1
 6fi
 7
 8# TODO: Add an option to ormolu to only print file names.
 9files=$(git diff --diff-filter=MA --cached --name-only | \
10	awk '/..*\.hs/' | \
11	xargs -r ormolu --mode check 2>&1 | \
12	awk '/[a-zA-Z.\/][a-zA-Z.\/]*\.hs/')
13
14if [ -n "${files}" ]; then
15	printf "The following files need to be formated with 'ormolu':\n\n" 1>&2
16	printf "%s\n" "${files}" | sed 's/^/\t/' 1>&2
17	exit 1
18fi