#!/bin/bash

input=${1}
if [[ ${input} == "" ]]; then
  input="-"
elif ! [[ -f ${input} ]]; then
  echo "Usage: ${0} [puppet file]"
  exit 1
fi

tempfile=$(mktemp)
cat "${input}" > "${tempfile}"
puppet-lint --fix "${tempfile}"  > /dev/null 2>&1
#puppet-lint --log-format "%{filename}:%{line}:%{column}: %{kind}: %{message}. [%{check}]" ${tempfile} | grep -v warning:
cat "${tempfile}"
rm "${tempfile}"