             [ring.adapter.jetty :as jetty]
             [ruuvi-server.core :as ruuvi-server]
             [ruuvi-server.database.entities :as entities]
+            [lobos.migrations :as migrations]
+            [ruuvi-server.database.load-initial-data :as load-initial-data]
             )
   (:use [clojure.tools.logging :only (debug info warn error)])
   (:gen-class))

          (= engine :aleph) (start-aleph-server config)
          :default (throw (IllegalArgumentException. (str "Unsupported server engine " engine ". Supported 'jetty' and 'aleph'."))))))

(defn- migrate [config]

  )

(defn- load-test-data [config]

  )

(defn- parse-command [values]
  (let [value (keyword (first values))]
        (cond (not value) :server
              :default (if (contains? #{:server :migrate :load-test-data} value)
                         value
                         (throw (IllegalArgumentException. "Command must be one of the 'server', 'migrate' or 'load-test-data'."))))))

(defn -main [& args]

    (cond (:help params) (display-end-text help)
          (:version params) (display-version))

    (let [[command & args] (parse-command commands-arg)
          config (load-config params)]
      ;; TODO replace with multimethod
      (cond (= command :server)
            (let []
              (println "RuuviServer starting")
              (start-server config args))

            (= command :migrate)
            (let []
              (println "Doing migration")
              (migrate config args))

            (= command :load-test-data)
            (let []
              (println "Load test data to database")
              (load-test-data config args))
            )
      )))
