Fork me on GitHub

I've recently started using to handle my programming language versions. There wasn't a babashka plugin for it yet, so I I haven't submitted a pull request to add it to the http://list%20, but that would be my next step.

babashka 1

Awesome. Feel free to PR some docs for the install instructions (please use [skip ci] in the commit message for only doc PRs)

David Pham12:12:00

Hello 🙂 I am referring to this issue on jet ( I have an issue, I don't know how to solve: how do you transform the input stream *in* as string?


@neo2551 (slurp *in*) :)

David Pham12:12:34

thhanks 🙂

David Pham12:12:20

I get an exception: stream closed.

David Pham12:12:31

let me check


you can only read from it once



$ bb '(keys (yaml/parse-string (slurp *in*)))' < .circleci/config.yml
(:version :jobs :workflows)

David Pham12:12:55

Yep, my problem was for jet, the main read from a stream and expect to do so.

David Pham12:12:12

So I am circumventing the problem the problem by not supporting conversion from yaml

David Pham12:12:25

(I know it is weak)


I don't quite follow.

David Pham12:12:48

[reader (case from
                         :json (formats/json-parser)
                         :transit (formats/transit-reader)
                         :edn nil)
                next-val (case from
                           :edn #(formats/parse-edn edn-reader-opts *in*)
                           :json #(formats/parse-json reader keywordize)
                           :transit #(formats/parse-transit reader))
                collected (when collect (vec (take-while #(not= % ::formats/EOF)
                                                         (repeatedly next-val))))]
This is from the main namespace of jet. I did not manage to make work with input stream here.


@neo2551 you might first want to do this PR: :)


but I'm not sure what the problem is you're running into

David Pham12:12:45

in the namespace there is a loop somehow, and if you slurp the *in* once, it will throw an error.


@neo2551 Let's discuss this in #jet


(defn clojure
  "Starts clojure similar to CLI. Use `rlwrap bb` for `clj`-like invocation.
  Invokes java with babashka.process/process for `-M`, `-X` and `-A`
  and returns the associated record. Default options passed to
  babashka.process/process are:

  {:in  :inherit
   :out :inherit
   :err :inherit
   :shutdown p/destroy-tree}

  which can be overriden with opts.

  Returns `nil` and prints to *out* for --help, -Spath, -Sdescribe and


  (-> (clojure '[-M -e (+ 1 2 3)] {:out :string}) deref :out) returns

  (-> @(clojure) :exit) starts a clojure REPL, waits for it
  to finish and returns the exit code from the process."
^ proposal for babashka.deps/clojure, a function to launch a Clojure process from within babashka (without installing additional tools but java).


Here's a screenshot for how it's supposed to work:


$ bb "(->> (deps/clojure '[-X:deps tree :format :edn] {:out :string}) deref :out edn/read-string :children keys (take 2))"
(org.clojure/clojure org.clojure/tools.cli)