Fork me on GitHub
#babashka
<
2022-11-28
>
stathissideris14:11:19

Hello, when using -x I get CLI params parsing for “free”, but when I use the task runner I get a more “raw” version of the params in *command-line-args*. If there a way to get the same parsing in the task runner?

borkdude14:11:20

@stathissideris yes :) use :task (exec 'my.ns/my-fn) and your function will be called with the parsed arguments map

stathissideris14:11:54

follow up: is one of -x/tasks runner the preferred way to do things? or are they both considered ok and you pick whichever you like?

borkdude14:11:33

pick whichever you like, but I find the task runner the easiest to remember the things you can do in a project

stathissideris14:11:25

yeah I suppose it’s like a high-level doc of some sort… and dependencies/parallel tasks are pretty neat 🙂

borkdude14:11:47

exactly, you jump into a project, run bb tasks and the project is self-documenting

stathissideris14:11:02

any advice for making task runner tasks available globally in a system? I’m writing a postgresql helper tool and I’d like to be able to run it from anywhere in the system. I think I’ll define an alias in my shell, but I’m not sure how it will behave in terms of directories etc

borkdude14:11:09

this isn't really what the task runner is for, you should think of the task runner as a Makefile-like replacement. To make global tools, I recommend writing a script or github repo and then make it installable with #babashka-bbin https://github.com/babashka/bbin you will have to implement the CLI yourself in this case, using the babashka.cli library you can find some examples here: https://github.com/borkdude/tools

stathissideris14:11:05

thanks for pointing me in the right direction… I’ll try to get it the code right first and then convert it

borkdude14:11:38

the shared part of these things is the library interface, you can use a library in tasks and in tools

stathissideris14:11:50

(you’re like an one-man ecosystem 😄 )

borkdude14:11:10

lol :) luckily there are some people helping me out ;)

borkdude14:11:28

you can also specify default args with :exec-args {...}

ericdallo19:11:08

Latest clojure-lsp bb pod tests started to fail after a change on clojure-lsp 🧵

ericdallo19:11:34

#error {                                                                                                                                                                                      
 :cause Not supported: class clojure_lsp.internal_api$clean_ns_BANG__STAR_$fn__34827                                                                                                          
 :via                                                                                                                                                                                         
 [{:type java.lang.RuntimeException                                                                                                                                                           
   :message java.lang.Exception: Not supported: class clojure_lsp.internal_api$clean_ns_BANG__STAR_$fn__34827                                                                                 
   :at [com.cognitect.transit.impl.WriterFactory$1 write WriterFactory.java 65]}                                                                                                              
  {:type java.lang.Exception                                                                                                                                                                  
   :message Not supported: class clojure_lsp.internal_api$clean_ns_BANG__STAR_$fn__34827                                                                                                      
   :at [com.cognitect.transit.impl.AbstractEmitter marshal AbstractEmitter.java 195]}]
 :trace
 [[com.cognitect.transit.impl.AbstractEmitter marshal AbstractEmitter.java 195]
  [com.cognitect.transit.impl.JsonEmitter emitMap JsonEmitter.java 171]
  [com.cognitect.transit.impl.AbstractEmitter emitMap AbstractEmitter.java 86]
  [com.cognitect.transit.impl.AbstractEmitter marshal AbstractEmitter.java 185]
  [com.cognitect.transit.impl.AbstractEmitter marshalTop AbstractEmitter.java 212]
  [com.cognitect.transit.impl.JsonEmitter emit JsonEmitter.java 41]
  [com.cognitect.transit.impl.WriterFactory$1 write WriterFactory.java 62]
  [cognitect.transit$write invokeStatic transit.clj 171]
  [cognitect.transit$write invoke transit.clj 168]
  [pod.clojure_lsp.api$write_transit invokeStatic api.clj 70]
  [pod.clojure_lsp.api$write_transit invoke api.clj 68]
  [pod.clojure_lsp.api$run_pod$fn__41678 invoke api.clj 116]
  [pod.clojure_lsp.api$run_pod invokeStatic api.clj 108]
  [pod.clojure_lsp.api$run_pod invoke api.clj 85]
  [clojure_lsp.main$handle_action_BANG_ invokeStatic main.clj 156]
  [clojure_lsp.main$handle_action_BANG_ invoke main.clj 149]

borkdude19:11:18

functions can't be serialized over the write

borkdude19:11:23

this is a transit error you're seeing

ericdallo19:11:34

yeah, just realized that

borkdude19:11:31

what's the use case of this function?

ericdallo19:11:08

it's not relevant for bb pod actually, the clojure-lsp.internal-api is called by: • cli • editor • bb pod

ericdallo19:11:19

could we dissoc or ignore it on the pod code?

borkdude19:11:03

define "pod code"

ericdallo19:11:45

Fixed in not a ideal way dissocing it, but will improve it later, thanks

👍 1
dharrigan20:11:53

Has anyone before talked about the possibility of compiling babashka scripts into a standalone executable?