Oh, right, options are nested.
This commit is contained in:
parent
eaf901c050
commit
9ab84d6e96
@ -183,15 +183,15 @@
|
|||||||
(with-out-str (clojure.pprint/pprint o)))
|
(with-out-str (clojure.pprint/pprint o)))
|
||||||
|
|
||||||
(defn get-args [keys args]
|
(defn get-args [keys args]
|
||||||
(let [input-opts (parse-opts args cli-opts)
|
(let [{:keys [options arguments errors summary]} (parse-opts args cli-opts)
|
||||||
opts (into {} (map (partial get-key input-opts) keys))
|
resolved (into {} (map (partial get-key options) keys))
|
||||||
missing (filter (fn [k] (not (get opts k))) keys)]
|
missing (filter (fn [k] (not (get resolved k))) keys)]
|
||||||
(cond (:help opts) (exit! 0 (:summary opts))
|
(cond (:help options) (exit! 0 summary)
|
||||||
(:errors opts) (exit! 1 (str/join \newline (:errors opts)))
|
errors (exit! 1 (str/join \newline errors))
|
||||||
(not (empty? missing)) (exit! 2 (str "missing arguments: " (str/join " " (map name missing))
|
(not (empty? missing)) (exit! 2 (str "missing arguments: " (str/join " " (map name missing))
|
||||||
\newline
|
\newline
|
||||||
"available: " (pprint-to-string opts)))
|
"available: " (pprint-to-string opts)))
|
||||||
:else opts)))
|
:else resolved)))
|
||||||
|
|
||||||
(defn -main [& args]
|
(defn -main [& args]
|
||||||
(let [required-keys [:exchange-host
|
(let [required-keys [:exchange-host
|
||||||
|
Loading…
x
Reference in New Issue
Block a user