 (ns ui.core
   (:require [figwheel.client :as fw :include-macros true]
             [reagent.core :as reagent :refer [atom]]
-            [clojure.string :as string]))
+            [clojure.string :as string :refer [split-lines]]))
+
+(defn join-lines [v] (string/join "\n" v))
 
 (enable-console-print!)
 

                            (.-value (.-target e))))
       :value @command
       :placeholder "type in shell command"}]]]
   [:pre @shell-result]])

(reagent/render
  [root-component]


(defonce proc (js/require "child_process"))

(defn append-to-out [out]
  (swap! shell-result str out))

(defn run-process []
  (let [[cmd & args] (string/split @command #"\s")
        p (.spawn proc cmd (clj->js args))]
    (.on p "error" (comp append-to-out
                         #(str % "\n")))
    (.on (.-stderr p) "data" append-to-out)
    (.on (.-stdout p) "data" append-to-out))
  (reset! command ""))

(defn root-component []
