babashka

https://github.com/babashka/babashka. Also see #sci, #nbb and #babashka-circleci-builds .
Daniel Stephens 2021-01-29T18:24:59.196Z

hi there, thanks for an amazing tool! I see in the github readme it says a few java classes that are available for interop, https://github.com/babashka/babashka#goals I was wondering what dictates that selection of supported things, is it a manual process to support each new class? Specifically I was reading through https://vlaaad.github.io/tools-cli-in-10-lines-of-code and thought about trying it in babashka but the clojure.lang.Compiler isn't present so some bits in the help script don't work. It was just a toy so I'm not too fussed and I can write something to add the docs to the metadata but I was interested in what changes what's available. Thanks!

borkdude 2021-01-29T18:28:59.197800Z

@dstephens The included classes dictate what you can do with interop, that is correct. We don't include clojure.lang.Compiler since this is generally not something you should probably need for scripting. The function demunge he is using is available in both clojure.repl and clojure.main:

$ bb -e '(clojure.main/demunge "foo_bar")'
"foo-bar"
$ bb -e '(clojure.repl/demunge "foo_bar")'
"foo-bar"

borkdude 2021-01-29T18:29:26.198100Z

So probably you can port it using those functions

borkdude 2021-01-29T18:29:44.198400Z

btw, tools.cli is also available in bb

borkdude 2021-01-29T18:34:16.199300Z

@dstephens I'm not sure why @vlaaad defines the help function like this:

(defn help [f]
  (println (:doc (meta (resolve (symbol (Compiler/demunge (.getName (class f)))))))))
since there is already clojure.repl/doc which does the same thing, except that it is a macro. Maybe that is his reason.

borkdude 2021-01-29T18:37:54.200800Z

The function equivalent of clojure.repl/doc would be:

bb -e '(clojure.repl/print-doc (meta (var inc)))'

borkdude 2021-01-29T18:38:32.201400Z

or:

$ bb -e "(clojure.repl/print-doc (meta (resolve 'inc)))"

Daniel Stephens 2021-01-29T18:39:06.202100Z

Ahh thanks, that's very interesting, yeah I did try with doc as my initial thought but it didn't pan out. Ohh nice, I'll give that a shot. As you point out, I'm pretty happy to use tools.cli as well, but it's fun experimenting 👍

borkdude 2021-01-29T18:39:21.202400Z

sure! :)

vlaaad 2021-01-29T20:21:27.202800Z

Because that's not a macro :P

borkdude 2021-01-29T20:41:44.203Z

:)