Morning 🙂
I want to write a super-light Emacs thing to run Babashka tasks. Is the best way to get a list of tasks to run bb tasks and ignore the first two lines?
I believe something like this already exists, let me check...
a quick online search linked me to this: https://github.com/licht1stein/babashka.el
it may not be what you want 100% but might be a good starting point
Absolutely! It gives me an example of how to do it.
For the record, I guessed maybe bb tasks could take some argument, bb tasks --lines or bb tasks --edn, but it appears it didn't take any arguments.
yeah, although --edn would be almost exactly the bb.edn file itself?
Right, (keys (:tasks (read-string (slurp "bb.edn")))) is probably preferred if you're already in an EDN friendly environment!
you could also invoke bb itself to produce the output you want in emacs
I immediately hit this parseedn limitation: https://github.com/clojure-emacs/parseedn/issues/18
In summary, clojure.core/read-string and clojure.edn/read-string both parse "(exec 'tasks/create-post)" fine, whereas parseedn.el crashes, quotes are not supported.
A workaround appears to be replacing ' with quote, like (parseedn-read-str "(exec (quote tasks/create-post))").
just invoke bb with "bb "-e" "(whatever-program-you-like-to-massage-your-data)" I guess? you already have bb to your disposal, so why bother
I want a generic bb task runner! We already https://github.com/magnars/emacsd-reboot/blob/02bf9e4ce9de3f10bf00f8423f796ae7418faa36/packages/setup-makefile-mode.el#L78-L111 for running Makefile tasks from inside of Emacs.
With the same tooling for bb, another argument for Makefiles disappears.
I meant, why bother with an emacs package to parse EDN if you can shell out to bb to accomplish that
for your package
what I mean is: you can shell out in your bb tasks emacs package to bb to massage the data you can then use in emacs
(to be more explicit)
aaaah, right. Got it 👍
if the linked babashka tasks package also hits that problem, I suggest changing it in that way too
there's many bb.edns around with quotes
Yeah, I have quotes in about every bb.edn I write myself, for calling into my own code in tasks.
> if the linked babashka tasks package also hits that problem, I suggest changing it in that way too Agreed, that's probably the way to go.
got it working by shelling out. Thanks for the suggestion! There was already an issue for this problem, so I added a comment. https://github.com/licht1stein/babashka.el/issues/5#issuecomment-3426350488
I was thinking about a similar thing last week when I was toying with a carapace completer for bb. The only use case I was thinking of was the case of an alternate bb.edn file, (e.g. bb --config some-other-file.edn , but I think that's probably YAGNI almost all the time.
yeah, I've been having some fun with it... my hope is to get that custom completer to something I feel good about (still very much a WIP), and then post it and maybe see about PR'ing a link to it into the bb book in the shell completion section
nice. there's also an open issue for babashka.cli to generate autocompletions for CLIs. I wonder if this tool can help with that somehow. are you still on windows btw (and it thus helps on windows too?)
I'm no longer on windows in general (still have to deal with it at work), but carapace can do completion on windows on supported shells (e.g. powershell, and regular cmd if you've got some bolt-ons). Having something that'd generate completions would be a win, and maybe it's worth considering if carapace should be on the list of the completions that can be generated (there's a yaml format that's sort of ugly, but generally workable). That could be a way to provide a bridge and say "we'll make (e.g.) bash and fish completions, and a carapace completion that can be used from a bunch of shells". So there's a route to getting completions without bb.cli becoming a library that mostly deals with generating completions, and does a little arg parsing on the side. :) I believe that carapace can also do 'bridging' (https://carapace-sh.github.io/carapace-bin/spec/bridge.html), but I haven't messed with that at all, because a lot of the extant stuff in that space looks to be aimed at the golang ecosystem. If we wanted to get crazy, we could see about contributing a bridge that'd let people say "this program is a bb.cli thing, figure out the completions for me" (but that's probably a bigger undertaking).
I'll see if I can organize some coherent thoughts after work and throw a comment on that bb.cli issue - I'll poke around and see if there's anything in carapace about gen'ing completions for shells, but I think it's primarily aimed at being an "abstraction" that can decomplect completions from shell-specific impls.
I apologize for the wall of text on the discussion - I think the completion topic is a prime area for considering prior art. 🙂
I'm writing and wraping some hello-wolrd bb script with the minimal possible size, the script run fine most of time. But when I run the script inside a repo with some bb.edn, the script(or rather bb) got confused and start looking for clojure-tools. How do I tell bb that this is a simple script, bb.edn is not relevant, do NOT look or download clojure-tools for me, just run this hellow-world?
Only if there are :deps inside the bb.edn will bb try to download them. If you don't want this, you can either
• move the script
• move the :deps to :extra-deps of a task (assuming you have deps to run tasks)
• set the config to something else: --config nil
• set the classpath to something empty: bb -cp "" ...
Thanks. I just need some portable script run reliably no matter which directory it sits. --config nil and -cp "" both works this case.