Fork me on GitHub
#babashka
<
2022-01-14
>
Benjamin14:01:32

do you have an idea if I can make a simple ui with a dropdown/ some completion thing for some elements with bb? It's for windows users else I'd consider dmenu

borkdude14:01:00

If you're looking for a UI app I would use either httpkit (webserver in bb) + HTML or use #nbb (node.js) with Ink (react in the terminal)

borkdude14:01:49

it's pretty awesome, works on windows too

Benjamin14:01:18

man I bet this is like candy

borkdude14:01:23

I created an example with a dropdown.

borkdude14:01:29

(ns script
  (:require ["ink" :refer [render]]
            ["ink-select-input$default.default" :as SelectInput]
            [reagent.core :as r]))

(def items (clj->js [{:label "First"
                      :value "first"}
                     {:label "Second"
                      :value "second"}]))

(defn handle-select [i]
  (js/console.log i)
  (js/process.exit 0))

(defn select []
  [:> SelectInput {:items items :onSelect handle-select}])

(render (r/as-element [select]))

borkdude14:01:49

package.json:

{
  "dependencies": {
    "ink": "^3.2.0",
    "ink-select-input": "^4.2.1",
    "nbb": "^0.1.1",
    "react": "^17.0.2"
  }
}

Dimitar Uzunov15:01:01

Do you guys always shell out when using git in babashka? Any recommended patterns?

borkdude15:01:13

shell is from babashka.tasks

Dimitar Uzunov15:01:55

yeah that is what I’ve been doing so far, although I used mostly the clojure.java.shell/sh

borkdude15:01:25

shell has the following benefits/differences: you see the output as you execute it and it parses the command string for you, so you don't have to split it manually

☝️ 1
borkdude15:01:51

also: on Windows, it resolves executables like gu.cmd when you execute (shell "gu")