#!/bin/sh set -e usage () { echo "Usage: serve [--jit] Serve the site pages fetch [--jit] Populate the database with records" } serve () { variant="$1" if [ "$variant" = "--jit" ]; then echo "running jit" go run -tags fts5,jit ../. -n 1 main.lua bin/serve.fnl else echo "running puc" LUA_CPATH="/usr/local/lib/lua/5.4/?.so;/usr/local/lib/lua/5.4/loadall.so;./?.so;$(guix build lua-lpeg)/lib/lua/5.3/?.so" \ go run -tags fts5,puc ../. -n 1 main.lua bin/serve.fnl fi } fetch () { if [ "$variant" = "--jit" ]; then echo "running jit" go run -tags fts5,jit ../. -n 1 main.lua bin/fetch.fnl else LUA_CPATH="/usr/local/lib/lua/5.4/?.so;/usr/local/lib/lua/5.4/loadall.so;./?.so;$(guix build lua-lpeg)/lib/lua/5.3/?.so" \ go run -tags fts5,puc ../. -n 1 main.lua bin/fetch.fnl fi } cmd="$1" [ -z "$cmd" ] || [ "$cmd" = "-h" ] || [ "$cmd" = "--help" ] && usage && exit 1 shift "$cmd" "$@" || usage