summaryrefslogtreecommitdiff
path: root/Biz/Ide/repl
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2022-07-20 10:42:23 -0400
committerBen Sima <ben@bsima.me>2022-07-20 10:42:23 -0400
commit710fd36b32fdf61c5858fd8d7f47891f07fa90d9 (patch)
treec4ee3fb2f7578914efce300ce1ed91b0b3204ef9 /Biz/Ide/repl
parent7dd2fccd5f1d5ddefa18e9a25c16724ceb54a909 (diff)
Add PORT argument to repl
Also added -h help message.
Diffstat (limited to 'Biz/Ide/repl')
-rwxr-xr-xBiz/Ide/repl30
1 files changed, 21 insertions, 9 deletions
diff --git a/Biz/Ide/repl b/Biz/Ide/repl
index dfd8c3d..2ddbc4b 100755
--- a/Biz/Ide/repl
+++ b/Biz/Ide/repl
@@ -1,11 +1,20 @@
#!/usr/bin/env bash
-#
-# a simple complement to bild which only deals with launching repls
-#
-# > repl <target..>
-#
-# Starts a repl/shell for one or more targets. (Currently, all targets must have
-# the same extension for this to work.)
+###
+### a simple complement to bild which only deals with launching repls
+###
+### > repl <target..>
+###
+### Starts a repl/shell for one or more targets. (Currently, all targets must
+### have the same extension for this to work.)
+###
+### Repls started with this script should bind to `localhost:$PORT`.
+help() {
+ sed -rn 's/^### ?//;T;p' "$0"
+}
+if [[ $# == 0 ]] || [[ "$1" == "-h" ]]; then
+ help
+ exit 1
+fi
##
set -e
targets=${@:?}
@@ -14,6 +23,9 @@
exts=$(jq --raw-output '.namespace.ext' <<< $json | sort | uniq)
case $exts in
Hs)
+ if [ -z ${var+PORT} ]; then
+ echo "warn: repl: ghci does not support binding to a port"
+ fi
nix-shell \
--packages "(import $BIZ_ROOT/Biz/Bild.nix {}).private.ghcWith (h: with h; [$langdeps])" \
--command "ghci -i$BIZ_ROOT -ghci-script $BIZ_ROOT/.ghci ${targets[@]}"
@@ -26,12 +38,12 @@
nix-shell \
--packages "(import $BIZ_ROOT/Biz/Bild.nix {}).private.nixpkgs.guile_3_0" \
${flags[@]} \
- --command "guile -L $BIZ_ROOT -C $BIZ_ROOT/_/int --r7rs --listen"
+ --command "guile -L $BIZ_ROOT -C $BIZ_ROOT/_/int --r7rs --listen=${PORT:-37146}"
;;
Lisp)
nix-shell \
--packages "(import $BIZ_ROOT/Biz/Bild.nix {}).private.sbclWith (p: with p; [asdf swank $langdeps])" \
- --command "sbcl --eval '(require :asdf)' --eval '(require :swank)' --eval '(swank:create-server)' --load $targets"
+ --command "sbcl --eval '(require :asdf)' --eval '(require :swank)' --eval '(swank:create-server :port ${PORT:-4005})' --load $targets"
;;
*)
echo "unsupported targets: ${targets[@]}"