#!/bin/sh

if [ ! -f "$1" ]; then
	echo "Requires a jsonnet file path as an argument"
	exit 1
fi

outdir="$(dirname "$(readlink -f "$1")")"
filename="$(basename "$1")"

# Generate the yaml result
outfile="${outdir}/${filename%.*}.yml"
cat <<-EOF > "$outfile"
---

# Auto-generated with Jsonnet from $filename
# Do NOT edit!!

EOF
jsonnet --string "$1" >> "$outfile"
printf "=> Generated YAML output for \033[1;34m%s\033[0m\n" "$1"
