babashka

https://github.com/babashka/babashka. Also see #sci, #nbb and #babashka-circleci-builds .
russmatney 2021-04-24T02:58:26.473Z

I updated it to just remove quotes completely for now, so it should work for those cases - feel free to ping me if there are other failures

vlad_poh 2021-04-24T06:56:08.473700Z

Hi anyone know of a way to read and write to excel with babashka?

borkdude 2021-04-24T09:11:43.474500Z

@kbosompem you could possibly shell out to some other CLI which can read excel. e.g.: https://csvkit.readthedocs.io/en/latest/scripts/in2csv.html

borkdude 2021-04-24T09:12:27.475400Z

Other options: Excel is XML right...., manually read the XML? I honestly don't know how hard this is. The other option would be to make an excel pod.

borkdude 2021-04-24T09:17:04.476Z

If you rename the excel to .zip you can unzip it and there you will see a bunch of XML files. Maybe it's not too hard :) :/ :-s

2021-04-24T14:23:07.476800Z

Is there a good way to get a repl with all of the namespaces in my `:requires` key processed? (also the default commands)

borkdude 2021-04-24T14:24:43.477100Z

@duck What kind of repl, just the command line REPL?

2021-04-24T14:26:41.478600Z

yeah. I found myself wishing that I had the same environment setup as I do in my task definitions. Figured there might be some easy way to acheive that

borkdude 2021-04-24T14:27:40.479600Z

@duck This is for debugging only but when you run with BABASHKA_DEV=true bb run foo it will run foo but also print the program needed to run. Maybe that can form the basis for such a REPL experience... worth experimenting.

borkdude 2021-04-24T14:28:18.479800Z

The program isn't pretty to look at btw

borkdude 2021-04-24T14:30:29.480300Z

It's probably better to write a tiny script that parses your :init and :requires and makes a starter script

borkdude 2021-04-24T14:30:45.480700Z

you can invoke (clojure.main/repl) at the end of that script

2021-04-24T14:31:08.481Z

worth looking into

2021-04-24T14:34:38.482200Z

just a simple repl (clojure.main/repl) task seems to be enough to drop me into user1 with my global requires available.

borkdude 2021-04-24T14:35:03.482400Z

wow nice!

borkdude 2021-04-24T14:35:22.482700Z

this is worth documenting, I'll put it in the issue

Karol Wójcik 2021-04-24T15:01:04.483600Z

Does babashka tasks support grouping subtasks?

Karol Wójcik 2021-04-24T15:01:27.484100Z

Something like: bb :build <subtasks>

borkdude 2021-04-24T15:02:10.484700Z

Not yet. I think just using a prefix like build-foo, build-bar could be the current way of grouping

borkdude 2021-04-24T15:09:59.485200Z

I do want to add something around this, but it's not yet clear at this point

Karol Wójcik 2021-04-24T15:10:23.485600Z

Ok thanks. May I specify the url to script file which is available on github?

borkdude 2021-04-24T15:10:52.485900Z

of course!

Karol Wójcik 2021-04-24T15:12:22.486300Z

Yay ❤️

borkdude 2021-04-24T15:19:46.488900Z

I am now adding some logging around tasks: 1) By default the task names are printed before execution 2) It can be suppressed globally using :log-level :error 3) or on individual task level 4) in private tasks the log-level is :error automatically 5) shell and clojure also print their command, they can be suppressed similarly 6) shell and clojure print a when their exit code is non-zero (with :log-level :info and :error) A binary to test this will be available shortly on #babashka-circleci-builds...

borkdude 2021-04-24T15:22:03.489400Z

example output from clj-kondo.lsp:

$ bb lsp-jar
&gt; java1.8
&gt; recent-clj-kondo
&gt; update-project-clj
&gt; build-server
&gt; lein with-profiles -user do clean, run -m clj-kondo.lsp-server.impl.version
Generation version file: 2021.04.23 &gt; ../vscode-extension/CLJ_KONDO_VERSION
&gt; lein with-profiles -user do clean, uberjar
Compiling clj-kondo.lsp-server.impl.server
Compiling clj-kondo.lsp-server.impl.version
Compiling clj-kondo.lsp-server.main
Created /Users/borkdude/Dropbox/dev/clojure/clj-kondo.lsp/server/target/lsp-server-2021.04.23.jar
Created /Users/borkdude/Dropbox/dev/clojure/clj-kondo.lsp/server/target/lsp-server-2021.04.23-standalone.jar
&gt; lsp-jar
#object[sun.nio.fs.UnixPath 0x157d3c8d "server/target/clj-kondo-lsp-server-2021.04.23-standalone.jar"]

Karol Wójcik 2021-04-24T15:23:16.489900Z

@borkdude where can I find some bb.edn file specification?

Karol Wójcik 2021-04-24T15:42:44.491200Z

Hmm. I got the same structure as antq https://github.com/borkdude/antq/blob/bb.edn/bb.edn. When I type bb tasks babashka says that there are no tasks

borkdude 2021-04-24T15:44:07.491700Z

I can't really diagnose anything if you link to something that is already working :)

👍 1
😆 1
Karol Wójcik 2021-04-24T15:47:20.491900Z

borkdude 2021-04-24T15:48:26.493Z

which bb version are you using and which branch of antq are we looking at

Karol Wójcik 2021-04-24T15:48:40.493300Z

We're looking at bb.edn branch

Karol Wójcik 2021-04-24T15:48:56.493600Z

Babashka v0.3.5

borkdude 2021-04-24T15:49:47.493800Z

try the bb-run branch

Karol Wójcik 2021-04-24T15:50:02.494Z

Works

Karol Wójcik 2021-04-24T15:51:27.494400Z

But tasks from script folder are not included

borkdude 2021-04-24T15:52:59.494600Z

I am not sure what you mean by this

Karol Wójcik 2021-04-24T16:36:35.496500Z

Isn’t it that paths for bb.edn specify where tasks are located?

Karol Wójcik 2021-04-24T16:37:31.497900Z

Therefore bb tasks should return list of tasks which are in script folder?

borkdude 2021-04-24T16:41:20.498700Z

@karol.wojcik That's not how it works. :paths is the classpath for bb, you can also have :deps, similar to deps.edn. The tasks are the symbols in the :tasks map

borkdude 2021-04-24T16:45:33.499200Z

I think in the antq bb.edn :paths isn't really used

Karol Wójcik 2021-04-24T16:51:15.499400Z

Ahhh ok

borkdude 2021-04-24T16:52:11.499700Z

Impressive bb.edn by @mike1452 : https://github.com/redstarssystems/rssyslib/blob/develop/bb.edn

🙌 3
richiardiandrea 2021-04-24T17:18:09.000100Z

Oh the requirement sections is a great idea!

Karol Wójcik 2021-04-24T18:09:07.003200Z

@borkdude Thank you so much. Last question though. Is it possible to provide doc for babashka task from source script? I would rather not provide doc inline. Here is what I'm trying to build

{:paths ["script"
         ;; "<https://github.com/FieryCod/holy-lambda/tree/master/modules/holy-lambda-babashka-tasks/script>"
         ]
 :tasks {:requires ([holy-lambda.tasks :as t])
         doctor t/doctor} ;; when runing `bb tasks` I would love babashka to take doc of task `doctor` from source code. 

 }

borkdude 2021-04-24T19:33:01.004600Z

@karol.wojcik Ah yeah, that's not yet supported yet, but I think that could work...

borkdude 2021-04-24T20:07:10.005500Z

One potential "danger" there could be that requiring a script to get the docstring takes time and could cause side effects (although if you use it like this, it should not have any)

👍 1
Karol Wójcik 2021-04-24T20:11:39.005900Z

Is there an issue for it?

borkdude 2021-04-24T20:12:28.006100Z

Not yet, please create one

borkdude 2021-04-24T20:13:01.006900Z

I will probably do a release tomorrow or so with that one in

Karol Wójcik 2021-04-24T20:13:06.007100Z

🙂

Karol Wójcik 2021-04-24T20:13:08.007300Z

Lovely

borkdude 2021-04-24T20:13:23.007700Z

Can I ask you for a favor? What OS do you use?

Karol Wójcik 2021-04-24T20:14:14.008600Z

Btw I'm experimenting with babashka tasks and I like it's design so far. Found also one bug which I will report as well.

Karol Wójcik 2021-04-24T20:14:24.009Z

Arch Linux

Karol Wójcik 2021-04-24T20:14:35.009500Z

Sure. Go ahead!

borkdude 2021-04-24T20:15:15.010300Z

Could you try out this binary: https://17698-201467090-gh.circle-artifacts.com/0/release/babashka-0.3.6-SNAPSHOT-linux-amd64.tar.gz (latest from #babashka-circleci-builds) I has additional "logging": it prints the task names (also of dependent tasks that are running) and I want to know if this is useful/obtrusive

borkdude 2021-04-24T20:16:06.010600Z

How it works is described here: https://github.com/babashka/babashka/discussions/779#discussioncomment-653726

Karol Wójcik 2021-04-24T20:16:10.010900Z

Checking!

Karol Wójcik 2021-04-24T20:27:55.011200Z

what is subcommand?

Karol Wójcik 2021-04-24T20:30:40.012600Z

Imho it looks fine, but still I would like to have an option to disable it or provide my own decoration fn.

borkdude 2021-04-24T20:45:41.013200Z

@karol.wojcik You can disable it with :log-level :error

borkdude 2021-04-24T20:45:52.013400Z

or :log-level :none

borkdude 2021-04-24T20:54:42.013700Z

but maybe a pluggable function is nicer

borkdude 2021-04-24T21:18:40.014800Z

Maybe

[bb] clean
is a nicer logging format :)

borkdude 2021-04-24T21:18:58.015Z

or:

[babashka] clean

👍 1
borkdude 2021-04-24T21:19:11.015200Z

I'll try that

borkdude 2021-04-24T21:27:16.016700Z

Example from antq:

$ clojure -M:babashka/dev lint
[babashka] Running: lint
[babashka] Shell: echo cljstyle
cljstyle
[babashka] Shell: clj-kondo --lint src:test
linting took 309ms, errors: 0, warnings: 0

borkdude 2021-04-24T21:28:05.017300Z

I could include the task name in the logging during the task, e.g.:

[babashka lint] Shell: clj-kondo --lint src:test

borkdude 2021-04-24T21:32:49.017900Z

$ bb lint
[bb lint] Starting
[bb lint] echo cljstyle
cljstyle
[bb lint] clj-kondo --lint src:test
linting took 304ms, errors: 0, warnings: 0

borkdude 2021-04-24T21:35:37.018400Z

I think that makes sense since bb lint is the exact same command you can invoke in the command line

borkdude 2021-04-24T21:44:13.018800Z

This might be a little bit annoying too btw:

$ bb lsp-jar
[bb java1.8] Starting
[bb recent-clj-kondo] Starting
[bb update-project-clj] Starting
[bb build-server] Starting
[bb lsp-jar] Starting

borkdude 2021-04-24T21:46:53.019100Z

Maybe I'll just remove this logging idea

borkdude 2021-04-24T21:47:35.019300Z

or put the default to :error logging

borkdude 2021-04-24T21:48:29.019800Z

I'll do that so we can start testing without annoying people with it

borkdude 2021-04-24T22:00:54.020400Z

ok it's now:

$ bb lint
cljstyle
linting took 357ms, errors: 0, warnings: 0
and
$ bb run --log-level info lint
[bb lint]
[bb lint] echo cljstyle
cljstyle
[bb lint] clj-kondo --lint src:test
linting took 306ms, errors: 0, warnings: 0