The problem at hand is that when I run my program with lein run
it gets to the (read-line)
part and I can't get out of it, meaning: read-line never returns.
Here is the relevant code:
(def command (atom ""))
(defn print-prompt []
(print "prompt> ")
(flush)
)
(defn ask-for-input []
(print-prompt)
(let [x (str (read-line))]
(println (str "User input: " x))
(reset! command x)
)
)
I never see the "User input: " string on screen.
The strange part is, if I run lein repl
and call (ask-for-input)
then it works correctly :S
Try lein trampoline run, it works.
The following is from leiningen FAQ:
Q: I don't have access to stdin inside my project.
A: This is a limitation of the JVM's process-handling methods; none of them expose stdin correctly. This means that functions like read-line will not work as expected in most contexts, though the repl task necessarily includes a workaround. You can also use the trampoline task to launch your project's JVM after Leiningen's has exited rather than launching it as a subprocess.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With