Skip to content

Commit

Permalink
feat: Add output-load-file-result-to-cmdline-interceptor
Browse files Browse the repository at this point in the history
  • Loading branch information
liquidz committed Feb 26, 2024
1 parent 50bc2a9 commit 559e978
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion resources/config.edn
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
:config-map {elin.handler.evaluate/evaluate {:interceptor {:includes [elin.interceptor.evaluate/output-eval-result-to-cmdline-interceptor]}}
elin.handler.evaluate/evaluate-current-expr {:interceptor #ref [:interceptor :preset :evaluation]}
elin.handler.evaluate/evaluate-current-list {:interceptor #ref [:interceptor :preset :evaluation]}
elin.handler.evaluate/evaluate-current-top-list {:interceptor #ref [:interceptor :preset :evaluation]}}
elin.handler.evaluate/evaluate-current-top-list {:interceptor #ref [:interceptor :preset :evaluation]}
elin.handler.evaluate/load-current-file {:interceptor {:includes [elin.interceptor.nrepl/output-load-file-result-to-cmdline-interceptor]}}}

:initialize {:export {"g:elin_http_server_port" #ref [:http-server :port]}}}

Expand Down
13 changes: 13 additions & 0 deletions src/elin/interceptor/nrepl.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[clojure.string :as str]
[elin.constant.interceptor :as e.c.interceptor]
[elin.constant.nrepl :as e.c.nrepl]
[elin.protocol.rpc :as e.p.rpc]
[elin.util.file :as e.u.file]
[elin.util.nrepl :as e.u.nrepl]
[exoscale.interceptor :as ix]))
Expand Down Expand Up @@ -35,3 +36,15 @@

:else
ctx))})

(def output-load-file-result-to-cmdline-interceptor
{:name ::output-load-file-result-to-cmdline-interceptor
:kind e.c.interceptor/nrepl
:leave (-> (fn [{:component/keys [host] :keys [response]}]
(let [msg (e.u.nrepl/merge-messages response)]
(if (e.u.nrepl/has-status? msg "eval-error")
(when-let [v (:err msg)]
(e.p.rpc/echo-message host (str/trim (str v)) "ErrorMsg"))
(e.p.rpc/echo-text host "Required."))))
(ix/when #(= e.c.nrepl/load-file-op (get-in % [:request :op])))
(ix/discard))})

0 comments on commit 559e978

Please sign in to comment.