Skip to content
Permalink
Browse files

command line support, jetty adapter

  • Loading branch information...
bradlucas committed Sep 18, 2019
1 parent 9581ccd commit 026ac4c4ab4fd0bc092f351e5766aef9d5c411ea
Showing with 40 additions and 7 deletions.
  1. +11 −2 project.clj
  2. +29 −5 src/imagelocation/core.clj
@@ -4,16 +4,25 @@
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
:url "https://www.eclipse.org/legal/epl-2.0/"}
:dependencies [[org.clojure/clojure "1.10.0"]

[compojure "1.6.1"]
[ring/ring-defaults "0.3.2"]]
[ring/ring-defaults "0.3.2"]

[ring/ring-jetty-adapter "1.7.1"]
[org.clojure/tools.cli "0.4.2"]

]

:repl-options {:init-ns imagelocation.core}

:plugins [[lein-ring "0.12.5"]]
:ring {:handler imagelocation.handler/app}
:profiles
{:dev {:dependencies [[javax.servlet/servlet-api "2.5"]
[ring/ring-mock "0.3.2"]]}})
[ring/ring-mock "0.3.2"]]}}

:main imagelocation.core
)



@@ -1,6 +1,30 @@
(ns imagelocation.core)
(ns imagelocation.core
(:require [clojure.pprint :as pp]
[clojure.string :as str]
[clojure.tools.cli :refer [parse-opts]]
[imagelocation.handler :as handler]
[ring.adapter.jetty :as jetty]))

(defn foo
"I don't do a whole lot."
[x]
(println x "Hello, World!"))

(def cli-options
[["-f" "--filename FILENAME" "Process FILENAME for location information"]
["-h" "--help" "Show help usage"]])

(defn usage [summary]
(->> ["Image Location"
""
summary
""]
(str/join \newline)))

(defn process-file [filename]
(pp/pprint (format "Process %s" filename)))


(defn -main [& args]
;; (config/load-config)
(let [{:keys [options arguments errors summary]} (parse-opts args cli-options)]
(cond
(:filename options) (process-file (:filename options))
(:help options) (println (usage summary))
:else (jetty/run-jetty handler/app {:port 4002}))))

0 comments on commit 026ac4c

Please sign in to comment.
You can’t perform that action at this time.