!/bin/sh

if [ -z "$1" ]; then

echo "Usage: ./bb2gem ARTICLE[.bb]"

exit 1

fi

name="${1%%.*}"

gawk -f bb2gem.gawk < "${name}.bb" > "${name}.gmi"

printf '\n\ngardenapple - %s\n\n=> ./ Linux and low-spec-ish gaming' "$(date -I)" >> "${name}.gmi"

echo "Possibly un-handled [TAG]s:"

grep '\[' < "${name}.gmi"

~/code/go/amfora/amfora "file://$(realpath "${name}.gmi")" || amfora "file://$(realpath "${name}.gmi")"

rm -i -- "${name}.bb"