forked from pyr/cyanite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cyanite.clj
36 lines (33 loc) · 1.08 KB
/
cyanite.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
(ns io.cyanite
"Main cyanite namespace"
(:gen-class)
(:require [io.cyanite.carbon :as carbon]
[io.cyanite.http :as http]
[io.cyanite.config :as config]
[clojure.tools.cli :refer [cli]]))
(set! *warn-on-reflection* true)
(defn get-cli
"Call cli parsing with our known options"
[args]
(try
(cli args
["-h" "--help" "Show help" :default false :flag true]
["-f" "--path" "Configuration file path" :default nil]
["-q" "--quiet" "Suppress output" :default false :flag true])
(catch Exception e
(binding [*out* *err*]
(println "Could not parse arguments: " (.getMessage e)))
(System/exit 1))))
(defn -main
"Our main function, parses args and launches appropriate services"
[& args]
(let [[{:keys [path help quiet]} args banner] (get-cli args)]
(when help
(println banner)
(System/exit 0))
(let [{:keys [carbon http] :as config} (config/init path quiet)]
(when (:enabled carbon)
(carbon/start config))
(when (:enabled http)
(http/start config))))
nil)