Skip to content

Instantly share code, notes, and snippets.

@wjlroe
Created January 21, 2012 00:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wjlroe/1650490 to your computer and use it in GitHub Desktop.
Save wjlroe/1650490 to your computer and use it in GitHub Desktop.
trying to read some input
(ns my-console.core)
(defn woot []
(while true
(print "cmd > ")
(flush)
(let [cmd (read-line)]
(println "you entered:" cmd))))
(defn -main
[& args]
(woot))
@wjlroe
Copy link
Author

wjlroe commented Jan 21, 2012

Here's what happens. It doesn't print the input:

0:40:18 will@rautavaara my-console $  lein run                                                                      
echo> hi
^C%      

@et4te
Copy link

et4te commented Jan 21, 2012

Might sound silly but, did you specify :main my-console.core in project.clj?

@wjlroe
Copy link
Author

wjlroe commented Jan 21, 2012

Yup, the problem here is that Leiningen is running Subprocess to launch your code, and that breaks input. So to make code like this work, you have to run lein trampoline run to quit the leiningen vm before launching your code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment