Source

messageme-clj / src / messageme / console.clj

Full commit
(ns messageme.console
  (:require [messageme.commands :as cmd]))

(def prompt-string "> ")

(def commands
  {"send" cmd/send
   "inbox" cmd/inbox
   "connect" cmd/connect
   "exit" cmd/exit})

(defn execute [[command & arg-str]]
  (if (commands command)
    (apply (commands command) arg-str)
    (println "Command" command "does not exist.")))

(defn -main []
  (println (str "Available comands: " (keys commands)))
  (loop []
    (print prompt-string) (flush)
    (let [input (vec (.split (read-line) " " 2))]
      (execute input))
  (recur)))