babashka

https://github.com/babashka/babashka. Also see #sci, #nbb and #babashka-circleci-builds .
frederic 2020-12-12T10:03:44.192Z

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.

1
borkdude 2020-12-12T10:05:19.192800Z

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

2020-12-12T12:07:00.194200Z

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?

borkdude 2020-12-12T12:07:27.194600Z

@neo2551 (slurp *in*) :)

2020-12-12T12:07:34.194800Z

thhanks 🙂

2020-12-12T12:08:20.195Z

I get an exception: stream closed.

2020-12-12T12:08:31.195400Z

let me check

borkdude 2020-12-12T12:27:26.195600Z

you can only read from it once

borkdude 2020-12-12T12:34:31.195800Z

@neo2551

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

2020-12-12T12:35:55.196300Z

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

2020-12-12T12:36:12.196800Z

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

2020-12-12T12:36:25.197100Z

(I know it is weak)

borkdude 2020-12-12T12:37:29.197300Z

I don't quite follow.

2020-12-12T12:39:48.198400Z

[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.

borkdude 2020-12-12T12:41:47.198700Z

@neo2551 you might first want to do this PR: https://github.com/clj-commons/clj-yaml/issues/3 :)

borkdude 2020-12-12T12:42:17.199200Z

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

2020-12-12T12:44:45.201200Z

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

borkdude 2020-12-12T12:44:56.201500Z

@neo2551 Let's discuss this in #jet

borkdude 2020-12-12T20:41:42.218Z

(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).

borkdude 2020-12-12T21:05:01.218600Z

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

borkdude 2020-12-12T22:31:09.219Z

$ 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)