     (= v (sub k))
     ))
 
-(defrecord Systems [] Repl 
-  (ls [this] 
+(defrecord Systems [] Repl
+  (ls [this]
     (with-admin
       (let [systems (into [] (s/systems-for (celestial.api.systems/working-username)))]
         [this {:systems (doall (map (juxt identity s/get-system) systems))}])))

(ns celestial.repl
  "Repl Driven Celestial "
  (:require 
    [celestial.persistency.systems :as s]
    [celestial.persistency.types :as t]
    [es.systems :as es :refer (set-flush)]


(def admin {
  :username "admin" :password "foo"
  :envs [:dev :qa :prod]
  :roles #{:celestial.roles/admin}
  :operations [] })

(defmacro with-admin [& body]
  `(with-redefs [celestial.security/current-user (fn [] {:username "admin"})
                celestial.persistency.users/get-user! (fn [a#] admin)]
       ~@body
       ))

(defprotocol Repl
  "Basic shell like functions on Celestial model types"
  (ls [this] [this & opts])
  (find [this exp])
  (rm [this items])
