Fork me on GitHub
#babashka
<
2022-01-19
>
mknoszlig10:01:51

Not sure if this is a common case, but i would like to bundle a set of tasks with a library, and to have them available to consumers of that library (maybe in the form of bb run <lib-name> <task-name>) i haven’t seen anything about that in docs/open issues, so maybe i’m coming from the wrong direction?

borkdude10:01:17

@maximilian right now there are these options: • write your tasks as normal functions and make a normal library • use that library in tasks and hook up task names to the library functions • or: use the --config (+ optionally --deps-root ) flags to refer to a different bb.edn

mknoszlig11:01:42

awesome, thanks! will have to meditate on that for a bit 🙂

borkdude11:01:50

still figuring out best practices around this, please share your experiences down the road ;)

borkdude09:01:23

One more thought I had: we could maybe make bb.edn's executable, by supporting:

#!/usr/bin/env bb
{:tasks ...}
If you would then rename that bb.edn to build or whatever and you would place it on your path, then you could do:
build tasks
build lint
build jar
etc.

borkdude09:01:47

Or whatever, e.g. for your unwordle project:

unwordle solve ...

teodorlu12:01:16

I think I'd be a bit surprised if it was suddenly possible to run a deps.edn file directly. But that might just be (lack of) familiarity.

borkdude10:01:58

@maximilian you can also just use bb -m foo/bar to run functions instead of tasks

borkdude10:01:29

so in your original request, the closest would be bb --config <your-bb.edn> run <task-name>

teodorlu11:01:51

Not all clojure code is valid babashka - due to the classloader, etc. Is all babashka code valid clojure code? Looking at https://github.com/weavejester/build/blob/master/src/weavejester/build/tasks.clj#L1 got me curious if those functions can be run in a normal clojure REPL, provided the right dependencies are present.

borkdude11:01:18

> Is all babashka code valid clojure code? Should be

👍 2
gigal00p20:01:44

Hi babashka users! I've made my first babashka script to generate .gitattributes file with file patterns that should be tracked by git-lfs. It's not about the code. It was more an experiment. I wanted to check how quickly I'll be able to glue things up for something I would normally use shell, Perl, Python or similar language. Wow. The whole process was really, really nice. Fast startup of babashka + nrepl + CIDER combo is really powerful. Thanks @borkdude for this amazing tool! For interested, repo is here: https://gitlab.com/gigal00p/bb-git-attributes

🎉 1
borkdude22:01:38

Thanks for sharing!