From de3edfca6fd628494be5e04ff3dbe21a54441163 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Tue, 19 Jul 2022 09:55:07 -0400 Subject: Support multiple targets in repl Also fixed a bug where the json failed to parse correctly. --- Biz/Ide/repl | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) (limited to 'Biz') 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 +# > repl # -# 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 -- cgit v1.2.3