Fork me on GitHub
#babashka
<
2019-12-30
>
Nate Sutton00:12:40

is there a way to satisfy an interface like FilenameFilter without reify?

borkdude00:12:27

is there maybe a new way of doing this in Java in nio?

Nate Sutton00:12:48

I could always do the filtering in clojure instead of that way

borkdude00:12:59

it seems useful for babashka to be able to do this, so we can maybe hack a special case for reify and this class together... not sure, have to think about it

Nate Sutton00:12:33

in the meantime I can just filter clojure-side

Nate Sutton00:12:59

I don't know if in the use cases for babashka it really matters where we filter the filenames

borkdude00:12:37

I guess there are also other ways of filtering files? like with normal clojure functions?

Nate Sutton00:12:50

yeah, that's what I mean

Nate Sutton00:12:56

sorry, not explaining well

borkdude00:12:09

oh I see 🙂

Nate Sutton02:12:15

I'm not sure what I'm doing wrong here but this file exists:

user=> (java.nio.file.Paths/get "deps.edn")
nil

Nate Sutton02:12:24

ahhh well that's odd

Nate Sutton02:12:25

user=> (java.nio.file.Paths/get "deps.edn" (make-array String 0))
#object[sun.nio.fs.UnixPath 0x23164e5e "deps.edn"]

Nate Sutton02:12:48

in the clojure repl I get this:

user=> (java.nio.file.Paths/get "deps.edn")
Execution error (ClassCastException) at user/eval9 (REPL:1).
class java.lang.String cannot be cast to class .URI (java.lang.String and .URI are in module java.base of loader 'bootstrap')

Nate Sutton02:12:16

and then in the clojure repl with two args I also get the same as in babashka

user=> (java.nio.file.Paths/get "deps.edn" (make-array String 0))
#object[sun.nio.fs.UnixPath 0x704b2127 "deps.edn"]

borkdude07:12:24

The ClassCastException may not be available in bb which is why you would get nil

borkdude09:12:38

I'll add it

borkdude10:12:09

$ bb '(shell/with-sh-env {:FOO "BAR"} (shell/sh "bash" "-c" "echo $FOO"))'
{:exit 0, :out "BAR\n", :err ""}

Nate Sutton11:12:30

yesss thanks!

Nate Sutton20:12:30

just fyi, btw, the --classpath option needs to be before the --repl option, not sure if that's as intended

Nate Sutton20:12:42

also the BABASHKA_CLASSPATH env var didn't seem to work with the repl

borkdude20:12:38

$ BABASHKA_CLASSPATH=. bb --repl
Babashka v0.0.56-SNAPSHOT REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=> (io/resource "deps.edn")
#object[.URL 0x61932785 "file:/Users/borkdude/Dropbox/dev/clojure/carve/deps.edn"]

borkdude20:12:08

The order of the arguments is indicated by:

Usage: bb [ -i | -I ] [ -o | -O ] [ --stream ] [--verbose]
          [ ( --classpath | -cp ) <cp> ] [ ( --main | -m ) <main-namespace> ]
          ( -e <expression> | -f <file> | --repl | --socket-repl [<host>:]<port> )
          [ --uberscript <file> ] [ arg* ]

borkdude11:12:18

I don't want to be dependent on the rules of a tool for parsing options

jeroenvandijk11:12:48

Thanks. Yes can imagine. Although tools.cli is somewhat low level and without side effects, it still has made some decisions for you

Nate Sutton20:12:17

I wonder what I was seeing last night with the classpath env var

Nate Sutton20:12:20

I'll have to try again

borkdude20:12:44

you'll probably need to use export when you're running another script

borkdude21:12:27

Made a thing to cut out the unused vars from a project: https://github.com/borkdude/carve Unleashing this on a script produced with --uberscript will make it even smaller.

borkdude21:12:54

(btw @lee it uses rewrite-cljc)

lread22:12:08

Coolio @borkdude! Has anybody ever mentioned you are whirlwind of productivity? I’ll be back to coding in the new year and drag rewrite-cljc through to an official release.

borkdude22:12:10

ok, let me know if you will remove the repo, so I can update my url/sha

borkdude22:12:19

but so far, it seems to work perfectly