[#234] *ns* should be controllable set per socket REPL connection

This commit is contained in:
Michiel Borkent 2020-01-20 10:41:11 +01:00 committed by GitHub
parent 9269f1087f
commit 8f698894f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 5 deletions

2
sci

@ -1 +1 @@
Subproject commit 641a1d943d8df4f7ffdf0f243dcda0ad54f7bad5 Subproject commit 3f448903550feaeb7d752c958f6422a5fde667f7

View file

@ -7,6 +7,7 @@
[clojure.tools.reader.reader-types :as r] [clojure.tools.reader.reader-types :as r]
[sci.impl.interpreter :refer [eval-form]] [sci.impl.interpreter :refer [eval-form]]
[sci.impl.parser :as parser] [sci.impl.parser :as parser]
[sci.impl.vars :as vars]
[sci.core :as sci] [sci.core :as sci]
[sci.impl.io :as sio])) [sci.impl.io :as sio]))
@ -58,7 +59,7 @@
expr)] expr)]
ret))) ret)))
:need-prompt (or need-prompt (fn [] true)) :need-prompt (or need-prompt (fn [] true))
:prompt (or prompt #(sio/printf "%s=> " (-> sci-ctx :env deref :current-ns))) :prompt (or prompt #(sio/printf "%s=> " (vars/current-ns-name)))
:flush (or flush sio/flush) :flush (or flush sio/flush)
:print (or print sio/prn) :print (or print sio/prn)
:caught (or caught repl-caught))))) :caught (or caught repl-caught)))))

View file

@ -14,9 +14,10 @@
(vars/bindRoot sci/err *err*) (vars/bindRoot sci/err *err*)
(defn repl! [] (defn repl! []
(start-repl! (init {:bindings {'*command-line-args* (sci/with-bindings {vars/current-ns (vars/->SciNamespace 'user)}
["a" "b" "c"]} (start-repl! (init {:bindings {'*command-line-args*
:env (atom {})}))) ["a" "b" "c"]}
:env (atom {})}))))
(defn assert-repl [expr expected] (defn assert-repl [expr expected]
(is (str/includes? (sci/with-out-str (is (str/includes? (sci/with-out-str