diff --git a/dev/dev.clj b/dev/dev.clj index a56d883..f5cc801 100644 --- a/dev/dev.clj +++ b/dev/dev.clj @@ -31,13 +31,13 @@ (tn/refresh-all)) (defn go - "Initializes and starts the system running." + "starts all defstate.s" [] (start) :ready) (defn reset - "Stops the system, reloads modified source files, and restarts it." + "stops all defstates, reloads modified source files, and restarts defstates" [] (stop) (tn/refresh :after 'dev/go)) diff --git a/src/mount/mount.clj b/src/mount/mount.clj index ea84900..b314db4 100644 --- a/src/mount/mount.clj +++ b/src/mount/mount.clj @@ -52,6 +52,12 @@ (throw (RuntimeException. (str "could not stop [" name "] due to") t))))) (alter-meta! var assoc :started? false))) +(defn find-states [] + (->> (all-ns) + (mapcat ns-interns) + (map second) + (filter #(= (:session-id (meta %)) session-id)))) + ;; TODO: narrow down by {:mount {:include-ns ;; {:starts-with ["app.foo" "bar.baz"] ;; :nss ["app.nyse" "app.tools.datomic"] } @@ -59,19 +65,16 @@ ;; {:starts-with ["dont.want.this" "app.debug"] ;; :nss ["dev" "app.stage"]}}} ;; -;; would come from lein dev profile -(defn- f-states [f order] - (->> (all-ns) - (mapcat ns-interns) - (map second) - (filter #(= (:session-id (meta %)) session-id)) +;; would come from boot/lein dev profile +(defn- bring [states fun order] + (->> states (sort-by (comp :order meta) order) - (map #(f % (meta %))))) + (map #(fun % (meta %))))) (defn start [] (doall - (f-states up <))) + (bring (find-states) up <))) (defn stop [] (doall - (f-states down >))) + (bring (find-states) down >)))