This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-14
Channels
- # adventofcode (1)
- # babashka (60)
- # beginners (107)
- # calva (11)
- # cider (3)
- # clara (11)
- # clj-kondo (6)
- # cljs-dev (33)
- # clojure (70)
- # clojure-dev (4)
- # clojure-europe (3)
- # clojure-italy (2)
- # clojure-kc (1)
- # clojure-losangeles (12)
- # clojure-nl (4)
- # clojure-spec (32)
- # clojure-uk (35)
- # clojuredesign-podcast (1)
- # clojurescript (28)
- # core-logic (4)
- # cursive (5)
- # datomic (34)
- # devcards (1)
- # emacs (16)
- # events (13)
- # fulcro (15)
- # graalvm (5)
- # graphql (3)
- # jobs (8)
- # joker (2)
- # kaocha (17)
- # malli (6)
- # music (3)
- # off-topic (58)
- # protorepl (7)
- # re-frame (28)
- # rewrite-clj (9)
- # shadow-cljs (102)
- # spacemacs (3)
- # sql (20)
- # tools-deps (9)
@borkdude I have opened a few new issues. I hope I will have chance to look into bb code today and fix some of them!
@holyjak Thanks. For the write issue, you might already be able to use spit with the append option for it
I've created this pull request https://github.com/borkdude/babashka/pull/106 I'm available for questions or remarks. Not sure how I should go about testing this
ah cool, I missed the submodule clone part 🙂 Thanks!
No I was just too quick
my bad
@borkdude I am trying to figure out how to add support for binding
but am lost. Would exposing clojure.core/binding work? But it is a macro , not a fn...
@holyjak Workaround for now maybe? https://github.com/borkdude/babashka/issues/103#issuecomment-553956952
This is how with-open
is supported:
https://github.com/borkdude/babashka/blob/5695ee3a52f056af3ca57a503bc3d296664e93a2/src/babashka/impl/clojure/core.clj#L12
Basically by coping the source and modifying it a bit for babashka.
Workaround: Yess, I will do that. But it feels suboptimal to open and close the file for each line I'm writing
I don't need it if I've write but it would be nice as it is I believe the standard way to do it in clojure, ie using print* with binding *out*
working on it (.write and .append that is)
that's good. I'm currently refactoring the interop bit, so it might become a lot easier to add classes in the future, just by adding something to reflection.json
I'm now trying support for interop using a reflection config. Seems to work well so far...
$ ./bb --verbose '(. "foo" (endsWith "o"))'
true
So maybe this will make adding classes easierIs it possible to replace the babashka process with a new process? Thus not using clojure.java.shell/sh
, but something like exec
in bash
I want to quickly validate commandline args with babashka and everything is ok, start a jar with the same args (long running process)
I think through Java, but maybe not
i guess that's the name
I would have to pipe the output to get proper feedback. sh
collects the output until the process terminates
Ok cool, I'll test that. Thanks
Btw, the reader conditionals are useful for what I'm trying
@jeroenvandijk this is embedded in babashka: https://github.com/clj-commons/conch#low-level-usage
fwiw, there was some discussion about using clojure.java.shell/sh
with pipe (look for openssl) on #clojure recently -- i think there might have been some success without using conch or java interop
user=> (clojure.java.shell/sh "sh" "-c" "echo U2FsdGVkX19YpBxGXZiFhpXjmogTE5OIbdQaHrXUIVQ=|openssl aes-256-cbc -d -a -pass pass:aaa")
conch works btw, but you have to manage the process underneath yourself and handle user input etc. So e.g. I just tried with a repl (`lein repl`) that fails in many ways 😁
what about making a wrapper bash script that first throws the command line args to babashka to validate and if that passes, continue with the actual process.
yeah I think that makes more sense
so:
#!/bin/sh
set -euo pipefail
bb '(assert (= 3 (count *command-line-args*)))' "$@"
# do the actual thing
echo "$@"
$ /tmp/script 1 2 3
1 2 3
$ /tmp/script 1 2 3 4
Assert failed: (= 3 (count *command-line-args*))
yeah I think that will work. Thanks 🙂
I added some evil 🙂 (https://github.com/borkdude/babashka/pull/107)
@borkdude When I run env BABASHKA_TEST_ENV=native script/test
or script/test
it gets stuck at
lein test babashka.impl.socket-repl-test
Does the test wait for me to connect to the socket repl or...?it should not get stuck. can you test the master version and see if you have the same problem?
I was on master of my fresh fork. Or have you changed something very recently?
I'm changing things all the time, but I test this locally and on CI, I don't notice anything strange. Could it be there is still a socket REPL open on your machine that it tries to connect to?
hm, that is possible
well, I had bb --socket-repl 1666
running. After killing it the tests passed.
interop via reflection is getting interesting:
$ ./bb "(map #(.getName %) [java.io.File java.lang.String])"
("java.io.File" "java.lang.String")
$ ./bb "java.io.File/pathSeparator"
":"
^ entirely using reflection, I haven't added a binding for that fieldThis is a work in progress branch with reflection support. So the only thing to do when adding support for a class to babashka is adding something to reflection.json
and the :classes
argument to sci. Then it should "just work TM".
Note the deletion of the babashka.impl.File
namespace:
https://github.com/borkdude/babashka/compare/reflect
The last two commits to sci were needed to support this: https://github.com/borkdude/sci/commits/master
This is what it looks like to add support for all methods + fields for Double
for example:
https://github.com/borkdude/babashka/commit/465f3b9b9fb12feebee3adf421e009e2b9b704ef
$ ./bb 'Double/MAX_VALUE'
1.7976931348623157E308