summaryrefslogtreecommitdiff
path: root/run.sh
diff options
context:
space:
mode:
authorunwox <me@unwox.com>2024-09-27 15:26:33 +0600
committerunwox <me@unwox.com>2024-09-27 15:44:16 +0600
commitdd449357f502dbe9ca4487d4b06a06ee4e597146 (patch)
tree9847488a6cc2c1aaf1fc80578e1a7a5d4af99ff5 /run.sh
parent9b82db238f9e2e02a76f95c793f8d6ef2387ecfd (diff)
new structure
Diffstat (limited to 'run.sh')
-rwxr-xr-xrun.sh36
1 files changed, 34 insertions, 2 deletions
diff --git a/run.sh b/run.sh
index f850f8d..89af2b3 100755
--- a/run.sh
+++ b/run.sh
@@ -1,3 +1,35 @@
#!/bin/sh
-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
+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