(defn- get-passkey1
[]
;; - not a good method, it can be copied back selecting where
;; text appears to be (cursor moves although nothing is printed)
;; - code is ugly as hell
;; - ansi control codes are not portable
(print (str "password: \033[8m"))
(flush)
(let [pass (read-line)]
(print (str "\033[K\033[0m")) ;; k should kill the line, but since read-line expects a newline,
;; I don't get to really kill it, so the pass is exposed
(flush)
pass))
(defn- get-passkey2
[]
;; - doesn't work as it initially fails due to a null pointer both with repl and lein run
;; - improves a little if run with lein trampoline run (not ideal), but
;; complains that there is no readPassword method that matches.
(let [console (System/console)]
(.readPassword console "Password: %s")))
;; this one needs (:import [jline.console ConsoleReader])
(defn- get-passkey3
[]
;; - in a repl this freezes the interpreter
;; - seems to work fine with lein run, but getting the whole
;; library for two lines of code seems expensive to me.
;; - still I'd go this route if this was the way to go (no freezing at least)
(print "Enter password")
(flush)
(let [cr (ConsoleReader.)]
(.readLine cr "password?" \*)))