Support for clj-http-lite
This commit is contained in:
parent
4ca9a81c1c
commit
3270d521d3
5 changed files with 68 additions and 62 deletions
|
|
@ -188,6 +188,11 @@
|
|||
"allPublicMethods" : true,
|
||||
"allPublicFields" : true,
|
||||
"allPublicConstructors" : true
|
||||
}, {
|
||||
"name" : "java.nio.file.Paths",
|
||||
"allPublicMethods" : true,
|
||||
"allPublicFields" : true,
|
||||
"allPublicConstructors" : true
|
||||
}, {
|
||||
"name" : "java.nio.file.StandardCopyOption",
|
||||
"allPublicMethods" : true,
|
||||
|
|
@ -353,21 +358,16 @@
|
|||
"allPublicMethods" : true,
|
||||
"allPublicFields" : true,
|
||||
"allPublicConstructors" : true
|
||||
}, {
|
||||
"name" : "javax.xml.bind.DatatypeConverter",
|
||||
"allPublicMethods" : true,
|
||||
"allPublicFields" : true,
|
||||
"allPublicConstructors" : true
|
||||
}, {
|
||||
"name" : "sun.net.www.protocol.http.HttpURLConnection",
|
||||
"allPublicMethods" : true,
|
||||
"allPublicFields" : true,
|
||||
"allPublicConstructors" : true
|
||||
}, {
|
||||
"name" : "sun.net.www.protocol.http.HttpURLConnection$HttpInputStream",
|
||||
"allPublicMethods" : true,
|
||||
"allPublicFields" : true,
|
||||
"allPublicConstructors" : true
|
||||
}, {
|
||||
"name" : "sun.net.www.protocol.https.HttpsURLConnectionImpl",
|
||||
"allPublicMethods" : true,
|
||||
"allPublicFields" : true,
|
||||
"allPublicConstructors" : true
|
||||
}, {
|
||||
"name" : "sun.nio.fs.UnixPath",
|
||||
"allPublicMethods" : true,
|
||||
|
|
|
|||
2
sci
2
sci
|
|
@ -1 +1 @@
|
|||
Subproject commit 577351c5514edb7492314048aef99d3c4319a667
|
||||
Subproject commit 6b75e1071ee425c6f468c73b2cef3ceae9c24af5
|
||||
|
|
@ -43,6 +43,7 @@
|
|||
java.nio.file.Files
|
||||
java.nio.file.NoSuchFileException
|
||||
java.nio.file.Path
|
||||
java.nio.file.Paths
|
||||
java.nio.file.StandardCopyOption
|
||||
java.nio.file.attribute.FileAttribute
|
||||
java.nio.file.attribute.PosixFilePermission
|
||||
|
|
@ -75,9 +76,8 @@
|
|||
java.util.zip.DeflaterInputStream
|
||||
java.util.zip.GZIPInputStream
|
||||
java.util.zip.GZIPOutputStream
|
||||
javax.xml.bind.DatatypeConverter
|
||||
sun.nio.fs.UnixPath ;; included because of permission check
|
||||
sun.net.www.protocol.http.HttpURLConnection ;; needed for clj-http.lite
|
||||
sun.net.www.protocol.https.HttpsURLConnectionImpl ;; needed fo clj-http.lite
|
||||
sun.net.www.protocol.http.HttpURLConnection$HttpInputStream ;; needed for clj-http.lite
|
||||
]
|
||||
:custom-classes {'java.lang.Thread
|
||||
|
|
|
|||
|
|
@ -21,8 +21,7 @@
|
|||
[clojure.string :as str]
|
||||
[sci.addons :as addons]
|
||||
[sci.core :as sci]
|
||||
[sci.impl.vars :as vars]
|
||||
[sci.impl.namespaces :as sci-namespaces])
|
||||
[sci.impl.vars :as vars])
|
||||
(:gen-class))
|
||||
|
||||
(set! *warn-on-reflection* true)
|
||||
|
|
@ -169,6 +168,8 @@ Everything after that is bound to *command-line-args*."))
|
|||
(edn/read {;;:readers *data-readers*
|
||||
:eof ::EOF} *in*))
|
||||
|
||||
(def reflection-var (sci/new-dynamic-var '*warn-on-reflection* false))
|
||||
|
||||
(defn load-file* [ctx f]
|
||||
(let [f (io/file f)
|
||||
s (slurp f)]
|
||||
|
|
@ -247,7 +248,8 @@ Everything after that is bound to *command-line-args*."))
|
|||
:namespaces {'clojure.core (assoc core-extras
|
||||
'*command-line-args*
|
||||
(sci/new-dynamic-var '*command-line-args* command-line-args)
|
||||
'*file* vars/file-var)
|
||||
'*file* vars/file-var
|
||||
'*warn-on-reflection* reflection-var)
|
||||
'clojure.tools.cli tools-cli-namespace
|
||||
'clojure.edn {'read edn/read
|
||||
'read-string edn/read-string}
|
||||
|
|
@ -288,52 +290,53 @@ Everything after that is bound to *command-line-args*."))
|
|||
main)
|
||||
expression)
|
||||
exit-code
|
||||
(or
|
||||
#_(binding [*out* *err*]
|
||||
(prn ">>" _opts))
|
||||
(second
|
||||
(cond version
|
||||
[(print-version) 0]
|
||||
help?
|
||||
[(print-help) 0]
|
||||
repl [(start-repl! ctx #(read-next *in*)) 0]
|
||||
socket-repl [(start-socket-repl! socket-repl ctx #(read-next *in*)) 0]
|
||||
:else
|
||||
(try
|
||||
(let [expr (if file (read-file file) expression)]
|
||||
(if expr
|
||||
(loop [in (read-next *in*)]
|
||||
(let [ctx (update-in ctx [:namespaces 'user] assoc (with-meta '*input*
|
||||
(when-not stream?
|
||||
{:sci.impl/deref! true}))
|
||||
(sci/new-dynamic-var '*input* in))]
|
||||
(if (identical? ::EOF in)
|
||||
[nil 0] ;; done streaming
|
||||
(let [res [(let [res (eval-string expr ctx)]
|
||||
(when (some? res)
|
||||
(if-let [pr-f (cond shell-out println
|
||||
edn-out prn)]
|
||||
(if (coll? res)
|
||||
(doseq [l res
|
||||
:while (not (pipe-signal-received?))]
|
||||
(pr-f l))
|
||||
(pr-f res))
|
||||
(prn res)))) 0]]
|
||||
(if stream?
|
||||
(recur (read-next *in*))
|
||||
res)))))
|
||||
[(start-repl! ctx #(read-next *in*)) 0]))
|
||||
(catch Throwable e
|
||||
(binding [*out* *err*]
|
||||
(let [d (ex-data e)
|
||||
exit-code (:bb/exit-code d)]
|
||||
(if exit-code [nil exit-code]
|
||||
(do (if verbose?
|
||||
(print-stack-trace e)
|
||||
(println (.getMessage e)))
|
||||
(flush)
|
||||
[nil 1]))))))))
|
||||
1)
|
||||
(sci/with-bindings {reflection-var false}
|
||||
(or
|
||||
#_(binding [*out* *err*]
|
||||
(prn ">>" _opts))
|
||||
(second
|
||||
(cond version
|
||||
[(print-version) 0]
|
||||
help?
|
||||
[(print-help) 0]
|
||||
repl [(start-repl! ctx #(read-next *in*)) 0]
|
||||
socket-repl [(start-socket-repl! socket-repl ctx #(read-next *in*)) 0]
|
||||
:else
|
||||
(try
|
||||
(let [expr (if file (read-file file) expression)]
|
||||
(if expr
|
||||
(loop [in (read-next *in*)]
|
||||
(let [ctx (update-in ctx [:namespaces 'user] assoc (with-meta '*input*
|
||||
(when-not stream?
|
||||
{:sci.impl/deref! true}))
|
||||
(sci/new-dynamic-var '*input* in))]
|
||||
(if (identical? ::EOF in)
|
||||
[nil 0] ;; done streaming
|
||||
(let [res [(let [res (eval-string expr ctx)]
|
||||
(when (some? res)
|
||||
(if-let [pr-f (cond shell-out println
|
||||
edn-out prn)]
|
||||
(if (coll? res)
|
||||
(doseq [l res
|
||||
:while (not (pipe-signal-received?))]
|
||||
(pr-f l))
|
||||
(pr-f res))
|
||||
(prn res)))) 0]]
|
||||
(if stream?
|
||||
(recur (read-next *in*))
|
||||
res)))))
|
||||
[(start-repl! ctx #(read-next *in*)) 0]))
|
||||
(catch Throwable e
|
||||
(binding [*out* *err*]
|
||||
(let [d (ex-data e)
|
||||
exit-code (:bb/exit-code d)]
|
||||
(if exit-code [nil exit-code]
|
||||
(do (if verbose?
|
||||
(print-stack-trace e)
|
||||
(println (.getMessage e)))
|
||||
(flush)
|
||||
[nil 1]))))))))
|
||||
1))
|
||||
t1 (System/currentTimeMillis)]
|
||||
(when time? (binding [*out* *err*]
|
||||
(println "bb took" (str (- t1 t0) "ms."))))
|
||||
|
|
|
|||
|
|
@ -319,6 +319,9 @@
|
|||
(is (thrown-with-msg? Exception #"error.bb"
|
||||
(bb nil (.getPath (io/file "test" "babashka" "scripts" "error.bb"))))))
|
||||
|
||||
(deftest compatibility-test
|
||||
(is (true? (bb nil "(set! *warn-on-reflection* true)"))))
|
||||
|
||||
;;;; Scratch
|
||||
|
||||
(comment
|
||||
|
|
|
|||
Loading…
Reference in a new issue