#!/bin/sh
PACKNAME=${1%.*}
OUTDIR="../OUT"
mkdir -p "$OUTDIR/assets"
printf "{\"$PACKNAME\":{" > "$OUTDIR/$PACKNAME.json"
printf "\"\":{" >> "$OUTDIR/$PACKNAME.json"
OUTNAME="$(sha256sum "$1" | awk '{ print $1 }').${1##*.}"
# _IMAGE_FILE = --usercard-image css var
printf "\"\$IMAGE_FILE\":\"$OUTNAME\"" >> "$OUTDIR/$PACKNAME.json"
if [ ! -z $2 ]; then
	printf ",\"--usercard-color\":\"$2\"" >> "$OUTDIR/$PACKNAME.json"
	if [ ! -z $3 ]; then
		printf ",\"--main-text\":\"$3\"" >> "$OUTDIR/$PACKNAME.json"
		if [ ! -z $4 ]; then
			printf ",\"--usercard-outline\":\"$4\"" >> "$OUTDIR/$PACKNAME.json"
		fi
	fi
fi
printf "}}}" >> "$OUTDIR/$PACKNAME.json"
