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!
@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"
So probably you can port it using those functions
btw, tools.cli is also available in bb
@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.The function equivalent of clojure.repl/doc
would be:
bb -e '(clojure.repl/print-doc (meta (var inc)))'
or:
$ bb -e "(clojure.repl/print-doc (meta (resolve 'inc)))"
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 👍
sure! :)
Because that's not a macro :P
:)