#!/bin/bash

if ! hash astyle; then
	echo "Warning: \`astyle\` is not available."
	exit 1
fi

cargo fmt --version >/dev/null 2>&1
if [[ $? != 0 ]]; then
	echo "Warning: \`cargo fmt\` is not available."
	exit 1
fi

info=$(make format-check)
if [ -n "$info" ]; then
	echo "Format Error detected:"
	echo
	echo "$info"
	echo
	echo "Please run \`make format\` before next commit."
	echo
	exit 1
fi
