summaryrefslogtreecommitdiff
path: root/Biz
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2022-07-19 09:55:07 -0400
committerBen Sima <ben@bsima.me>2022-07-19 09:55:07 -0400
commitde3edfca6fd628494be5e04ff3dbe21a54441163 (patch)
tree815c7fae04e1cdf368216f790cdb56a3110ba8ce /Biz
parentbc9e5b0ea863a17537987faa5a72b00efc7767d1 (diff)
Support multiple targets in repl
Also fixed a bug where the json failed to parse correctly.
Diffstat (limited to 'Biz')
-rwxr-xr-xBiz/Ide/repl36
1 files changed, 17 insertions, 19 deletions
diff --git a/Biz/Ide/repl b/Biz/Ide/repl
index 836bed9..0a6815f 100755
--- a/Biz/Ide/repl
+++ b/Biz/Ide/repl
@@ -2,35 +2,33 @@
#
# a simple complement to bild which only deals with launching repls
#
-# > repl <target>
+# > repl <target..>
#
-# Starts a repl/shell for target.
-#
-# - if target.hs, load ghci
-# - TODO: if target.scm, load scheme repl
-# - TODO: if target.nix, load 'nix repl'
+# Starts a repl/shell for one or more targets. (Currently, all targets must have
+# the same extension for this to work.)
##
set -e
- target=${1:?}
- json=$(bild --json "$target")
- langdeps=$(jq --raw-output '.[].langdeps | join(" ")' <<< $json)
- case $target in
- *.hs)
+ targets=${@:?}
+ json=$(bild --json ${targets[@]})
+ langdeps=$(jq --raw-output '.langdeps | join(" ")' <<< $json)
+ exts=$(jq --raw-output '.namespace.ext' <<< $json | sort | uniq)
+ case $exts in
+ Hs)
nix-shell \
- --packages "(import $BIZ_ROOT/Biz/Bild.nix {}).ghcWith (h: with h; [$langdeps])" \
- --command "ghci -i$BIZ_ROOT -ghci-script $BIZ_ROOT/.ghci $target"
+ --packages "(import $BIZ_ROOT/Biz/Bild.nix {}).private.ghcWith (h: with h; [$langdeps])" \
+ --command "ghci -i$BIZ_ROOT -ghci-script $BIZ_ROOT/.ghci ${targets[@]}"
;;
- *.scm)
+ Scm)
echo "scheme repl not supported yet: $target"
exit 1
;;
- *.lisp)
- swank-lisp-launcher.sh \
- --eval "(asdf:load-system 'swank)" \
- --eval "(swank:create-server :dont-close t)"
+ Lisp)
+ swank-lisp-launcher.sh \
+ --eval "(asdf:load-system 'swank)" \
+ --eval "(swank:create-server :dont-close t)"
;;
*)
- echo "unsupported target: $target"
+ echo "unsupported targets: ${targets[@]}"
exit 1
;;
esac