Files
inventory/make-card.sh
Kouya Heika b699c54539
Some checks failed
Inventory Packaging / package (push) Has been cancelled
Add more stuff:
* Classic smilies added: Kolobok, vB, Yolks
* Fixed card JSON files to use $IMAGE_FILE as a placeholder instead of a key
* New Frames
* Removed Pyong from make-all (incomplete naming)
2025-08-15 23:08:22 -05:00

25 lines
930 B
Bash
Executable File

#!/bin/sh
TARGET_DIRECTORY=${TARGET_DIRECTORY?-out}
INPUT=$1
_BASEDIR=`basename $INPUT`
PACK=${_BASEDIR%.*}
OUTNAME="$(sha256sum "$1" | awk '{ print $1 }').${1##*.}"
cp "$INPUT" "$TARGET_DIRECTORY/$OUTNAME"
echo "Writing card '$PACK'..."
if [[ $2 == '-' && -z $3 ]]; then
sed -e 's/$IMAGE_FILE/'$OUTNAME'/g' "${INPUT%.*}.json" > "$TARGET_DIRECTORY/$PACK.json"
exit;
fi
printf "{\"$PACK\":{" > "$TARGET_DIRECTORY/$PACK.json"
printf "\"\":{" >> "$TARGET_DIRECTORY/$PACK.json"
printf "\"--usercard-image\":\"$OUTNAME\"" >> "$TARGET_DIRECTORY/$PACK.json"
if [ ! -z $2 ]; then
[ $2 != '-' ] && printf ",\"--usercard-color\":\"$2\"" >> "$TARGET_DIRECTORY/$PACK.json"
if [ ! -z $3 ]; then
[ $3 != '-' ] && printf ",\"--main-text\":\"$3\"" >> "$TARGET_DIRECTORY/$PACK.json"
if [ ! -z $4 ]; then
printf ",\"--usercard-outline\":\"$4\"" >> "$TARGET_DIRECTORY/$PACK.json"
fi
fi
fi
printf "}}}" >> "$TARGET_DIRECTORY/$PACK.json"