#!/bin/sh
# Copyright (C) 2014 - 2018 FARGOS Development, LLC
# $Id$
# filter out compile/link errors
originDir=`dirname $0`
fileList=""
quiet=0
showWarnings=0
showColors=0

while test $# -gt 0
do
	case $1 in
	-h | -help | --help)
		printf "usage: %s [{-w | --nodeprecation}] [-c] [-q] [logFile ...]\n" "${0}" >&2
		printf "  -w = display warnings\n" >&2
		printf "  --nodeprecation = display warnings, except deprecation-related\n" >&2
		printf "  -c = display with color highlighting\n" >&2
		printf "  If no file specified, reads from stdin\n" >&2
		printf "  -q = suppress information message about reading from stdin\n" >&2
		exit 1
		;;
	-q)
		quiet=1	
		;;
	-w)
		showWarnings=1
		;;
	--nodeprecation)
		showWarnings=2
		;;
	-c)
		showColors=1
		;;
	-*)
		printf "%s: unrecognized option \"%s\"\n" "${0}" "${1}" >&2
		exit 1
		;;
	*)
		fileList="${fileList} ${1}"
		;;
	esac
	shift
done

if test -z "${fileList}" -a ${quiet} -eq 0
then
	printf "%s: reading build log from stdin\n" "${0}" >&2
fi

awk -v SHOW_WARNINGS=${showWarnings} -v SHOW_COLORS=${showColors} -f ${originDir}/filterErrors.awk ${fileList}
