This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-06
Channels
- # announcements (3)
- # asami (41)
- # aws (2)
- # babashka (65)
- # beginners (85)
- # biff (7)
- # calva (10)
- # cider (5)
- # cljsrn (32)
- # clojure (6)
- # clojure-czech (3)
- # clojure-europe (10)
- # clojure-russia (4)
- # clojure-uk (3)
- # clojurescript (5)
- # core-typed (7)
- # data-science (13)
- # datomic (43)
- # etaoin (4)
- # fulcro (22)
- # graphql (3)
- # gratitude (1)
- # helix (1)
- # joyride (2)
- # liquid (10)
- # malli (16)
- # off-topic (10)
- # other-languages (1)
- # polylith (10)
- # reitit (3)
- # scittle (7)
- # shadow-cljs (103)
- # tools-deps (10)
- # vim (9)
- # xtdb (2)
So with the new bb CLI library in place, should bb have an -x
mode where you can call single arg functions similar to clojure -X
but with the more unixy style?
bb -x foo.bar/baz --skip --name foobar
instead of:
clojure -X foo.bar/baz :skip true :name '"foobar"'
Seems like a nice addition to me. I generally prefer to wait until I have a specific use case before adding new stuff. I find it easier to judge whether it's a good solution then.
I'll probably wait with adding babashka.cli as a built-in until the nnext version
Hmm, actually the nbb -x ...
idea makes sense for nbb since it hasn't got a task runner and it's a cheap way to make CLIs
I'm looking for a simple (non-jvm) clojure code formatter, that I could plug into my editor - any suggestions? Maybe it's doable just using built-in bb functions?
@U03J48P76RW cljfmt also has a binary. but clojure-lsp can also be used as a binary CLI
clojure-lsp just uses cljfmt I think. cljstyle is derived from cljfmt if I'm not mistaking
Yes, cljstyle is based on cljfmt. I didn't know that clojure-lsp binary can be used for code formatting though
Hmm I didn't think of using an lsp - they don't always work with kakoune (my editor), but I'll try that first, before the binaries you mention, thanks both
It took me some time to realise that clojure-lsp works with my scripts, iff they have the .clj extension! Formatting works great, thanks again
@U03J48P76RW Doesn't it also just work when you enable clojure-mode
?
What's clojure-mode
? An emacs thing? My editor is kakoune, I have a filetype but it doesn't seem transmitted to lsp.
Never tried kakoune, but if it supports LSP it should work with clojure-lsp, LMK if need any help to setup the integration, we can also add a note on https://clojure-lsp.io/clients/
@UKFSJSM38 Does lsp depend on a .clj
extension or does it work in emacs when you set clojure-mode
regardless of the extension? (I know flycheck-clj-kondo
does work regardless of extension)
@U04V15CAJ it should not depend, but not sure if it works ATM, if not we should try to fix it
But it could have a performance impact if it has to inspect tons of non ".clj" files in the directory
No, this is something client does, not the server, your editor sends only the opened files, clojure-lsp then know what is your project and look for other clojure files
Hie, It might me a dumb question but is it possible to run tests from a leiningen project using babashka? Or individual deftest
from a lein project, instead of using lein test :only
@U027R1ML5RU Why would you not use lein? The alternative is to use deps.edn
with e.g. the cognitect test runner. Calling this from babashka would usually be done in bb.edn
tasks like this:
(apply clojure "-X:test" *command-line-args*)
Nice, the question was because lein sometimes takes a lot to load the dependencies and run the test and thought that maybe bb could help speed up for single test running 😊
@U027R1ML5RU I recommend doing this:
Install neil
: https://github.com/babashka/neil
Either using babashka or via the clojure CLI
And then invoke:
neil add test
It will add a deps.edn with the test runner.
And then you can run clj -X:test
to run testsIts a JVM normal project and I was trying to experiment with bb I'll give a look in neil
Thanks!
Kudos for babashka.process/exec—solves a wide class of problems I have for writing scripts around dealing with tons of AWS accounts :)
I think there’s something slightly hinky going on where the exec method of ProcessProperties actually wants you to provide the name of the program again as the first arg, C-args style, but I’m working around it by having my scripts just dupe the first item in the command list
$ bb -e “(babashka.process/exec [\“echo\” \“ok\“])” prints nothing
bb -e "(babashka.process/exec [\"echo\" \"echo\" \"ok\"])"
prints ok as expectedI will try to nail it down later—it’s weird because some programs respond to that missing arg by printing their usage (like ls
)
so I’m not 100% sure that’s what’s up
@U03J48P76RW You also ran into this right?
iiuc, you have the file with the binary image, and the name that will appear eg in ps or when the process inspects its own args
So maybe that's the 1% use case and we can have an option:
(proc/exec ["foo" ".."] {:arg0 "bar"})
or so?I saw this on the graalvm slack. Anyway, I know of at least one use case where you want a different program name than argv[0]
, https://github.com/kovidgoyal/kitty/blob/c8c6f8691f4aa84f4d798428af268319b898798f/kitty/child.py#L257. It is pretty rare though.
It looks like you have a solution you like, but my philosophy for wrapping existing APIs is: 1. provide a wrapper that maps as close as possible to the wrapped function 2. provide a separate, convenience wrapper that uses 1) (preferably with a different, suitable name). For someone who is trying to actually do something tricky that targets the wrapped API, it's much easier to use a minimally wrapped version rather than try to figure out which flags and options you need to pass to a convenience to function to map back to some call the underlying wrapped API function.
if we do want something more exec-like, the function could be (exec binary argv), eg (exec "/bin/blah" ["/bin/blah" "arg"])
, and could have a variant of (exec ["/bin/blah" "arg"])
Not familiar with overloading in clj
yes, this is possible, but I think with the :arg0
overridable option you get pretty much the same
We already have these overloads:
(exec [/bin/blah ...])
(exec [/bin/blah ...] {:env ..})