This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-07-19
Channels
- # babashka (39)
- # beginners (58)
- # calva (45)
- # clerk (9)
- # cljsrn (10)
- # clojure (23)
- # clojure-denver (13)
- # clojure-europe (39)
- # clojure-norway (6)
- # clojurescript (10)
- # clr (3)
- # cursive (5)
- # data-science (6)
- # datomic (27)
- # events (1)
- # fulcro (33)
- # graphql (5)
- # hyperfiddle (24)
- # introduce-yourself (4)
- # kaocha (1)
- # malli (8)
- # off-topic (23)
- # pedestal (5)
- # re-frame (2)
- # releases (4)
- # shadow-cljs (8)
- # xtdb (12)
I’m having trouble getting the mysql pod up and running:
#!/usr/bin/env bb
(ns user-lists)
(load-file (str (System/getProperty "user.home") "/.babashka/bb.clj"))
(require '[babashka.pods :as pods])
(pods/load-pod 'org.babashka/mysql "0.1.2")
(require '[pod.babashka.mysql :as mysql])
(def db {:dbtype "mysql"
:host "127.0.0.1"
:dbname "pearpop_dev"
:user "admin"
:password "XXXXXXX"
:port 3401})
(mysql/execute! db "select name from users")
This produces clojure.lang.ExceptionInfo: java.lang.Character cannot be cast to java.lang.String
Wrap the SQL in a vector
The error suggests a string has had a sequence function called on it (String -> Character) and then that first character is used where a string is expected.
Oh! Thank you. Wrapping it in a vector fixes it!
Oh :man-facepalming: all the examples have it wrapped in a vector too. I was somehow blind to that.
It's a common mistake, when there are no parameters, to try to just use a string... That's why I recognized the exception.
Thanks again.
I'm trying https://github.com/charmbracelet/gum with a https://github.com/lispyclouds/bblgum made by @rahul080327, I've just started playing with it, and filter
command seems to work only with input streams, but it should work with lists too as described.
==Clojure==
;; Works
(gum :choose ["Apple" "Banana" "Orange"])
;; Doesn't Works
(gum :filter ["Apple" "Banana" "Orange"])
My question is, is gum filter
intended to work with only input streams?
What if, I made long list of options from some nested data, I can't use gum filter
directly on it, I have to spit
it in a file first?
Before posting it here I tried gum filter
on terminal too, and it didn't worked same as gum choose
, which made me think, this isn't issue about wrapper, its either intended to work with inputs or I am making some mistake somewhere.
==Terminal==
;; Works
gum choose Apple Banana Orange
;; Doesn't Works
gum filter Apple Banana Orange
Does anyone have any idea about this?
✅ SOLVED by @borkdude@rahul080327
As per https://github.com/charmbracelet/gum/blob/d1ad453ce61aeb1181e5cf86ceb28c888ab92ff2/filter/command.go#L36, it takes only input via input stream, and the wrapper has`:in` option to pass desired input.
Hence, the only way to pass some data (other than input stream or file) to gum filter
in clojure (for now) is to pass data as string list:
(gum :filter :in (str/join "\n" data))
How can I input some sequence to gum filter in babashka? Do I have to spit it in a file first?
As per the source it only takes input on the stdin: https://github.com/charmbracelet/gum/blob/d1ad453ce61aeb1181e5cf86ceb28c888ab92ff2/filter/command.go#L36
@rahul080327 You didn't answer his question though ;)
Yeah looking for the option on the phone is harder 😆
I’m looking for a way to make a string an input stream. Join the seq with new lines and then send it
I have seen the go source but didn't get much, as per source, choose too reads via stdin, but it has a check that if options passed are 0, does that makes filter to think inputs passed as options? https://github.com/charmbracelet/gum/blob/d1ad453ce61aeb1181e5cf86ceb28c888ab92ff2/choose/command.go#L31C8-L31C8
If there’s no stdin, it filters the files in the current directory
This worked for me:
bb -cp src -e "(require '[bblgum.core :as b])" -e "(b/gum :filter :in (java.io.StringReader. \"foo\nbar\nbaz\"))"
That’s it
Can use (str/join \newline your-seq) to make the string
Can do it as soon as I have access to a machine and PR welcome!
I tried joining sequence with newline, but didn't give :in
with it :man-facepalming::skin-tone-3: because I thought this isn't input stream.
The examples in my README is pretty much a verbatim translation of the gum examples
But with filter
it seems :in
is necessary always, I was playing, trying without :in
supplying it a sequence, a string with newlines etc. and it wasn't working, but it seems filter
works with :in
only as it takes input stream only as its input.
Filter is designed in the same spirit as grep, compose on the command line
No not a string, if string was supported it should work (gum :filter "foo\nbar\nbaz")
but needs :in
always which takes string via input option. Avoiding confusion 😅
What we mean is a string also supported for :in and not just input streams.