Gra
Gra

Reputation: 1594

Read the user input in Clojurescript

I'm experimenting around a custom Lisp evaluator (reading Lisp in Small Pieces) in CLJS with Lumo.
Is there a way to ask the user for a string and then process it? Like the shell has read or Python has input.
Thanks.

Upvotes: 1

Views: 286

Answers (1)

akond
akond

Reputation: 16060

You could use nodejs readline package:

(def readline (js/require "readline"))
(def rl (.createInterface readline #js {:input (.-stdin js/process) :output (.-stdout js/process)}))

(.question rl "ok?" pr)

Upvotes: 2

Related Questions