Source

messageme-clj / src / messageme / console.clj

Full commit
(ns messageme.console
  (:require [messageme.core :as mm]))

(def prompt-string "> ")

(def commands
  {"send" mm/send
   "inbox" mm/inbox
   "connect" mm/connect
   "exit" mm/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)))