I've recently started using https://asdf-vm.com/#/ to handle my programming language versions. There wasn't a babashka plugin for it yet, so I https://github.com/fredZen/asdf-babashka. I haven't submitted a pull request to add it to the http://list%20https://asdf-vm.com/#/plugins-all, but that would be my next step.
Awesome. Feel free to PR some docs for the install instructions (please use [skip ci] in the commit message for only doc PRs)
Hello 🙂 I am referring to this issue on jet (https://github.com/borkdude/jet/issues/74) I have an issue, I don't know how to solve: how do you transform the input stream *in*
as string?
@neo2551 (slurp *in*)
:)
thhanks 🙂
I get an exception: stream closed.
let me check
you can only read from it once
$ bb '(keys (yaml/parse-string (slurp *in*)))' < .circleci/config.yml
(:version :jobs :workflows)
Yep, my problem was for jet, the main read from a stream and expect to do so.
So I am circumventing the problem the problem by not supporting conversion from yaml
(I know it is weak)
I don't quite follow.
[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: https://github.com/clj-commons/clj-yaml/issues/3 :)
but I'm not sure what the problem is you're running into
https://github.com/borkdude/jet/blob/master/src/jet/main.clj
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
-Stree.
Examples:
(-> (clojure '[-M -e (+ 1 2 3)] {:out :string}) deref :out) returns
\"6\n\".
(-> @(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)