~technomancy/fennel-lang.org

ref: c9a7db72fe3fd06b5eec936984713f034acd9511 fennel-lang.org/cli.fnl -rw-r--r-- 682 bytes
c9a7db72Phil Hagelberg Remove broken contributors link until we can get it fixed. 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
;; This is for running repl.fnl without having to start a browser.

(set package.preload.js (fn [] {:global {:console {:log print}}}))

(global narrate (fn [...] (io.write "| ") (print ...)))

(local fennel (require :fennel))
(table.insert package.loaders fennel.searcher)
(local repl (require :repl))

(var coro (coroutine.create repl))
(coroutine.resume coro)

(local read (fn [] (io.write "> ") (io.read)))

((fn loop [input]
   (if (= input ":reload")
       (do (set coro (coroutine.create (fennel.dofile "repl.fnl")))
           (coroutine.resume coro)
           (loop (read)))
       input
       (do
         (coroutine.resume coro input)
         (loop (read))))) (read))