From 9ab84d6e9686eef523be74fa4db97e186e5a145b Mon Sep 17 00:00:00 2001 From: niten Date: Mon, 20 Jun 2022 15:05:07 -0700 Subject: [PATCH] Oh, right, options are nested. --- src/pricebot/core.clj | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pricebot/core.clj b/src/pricebot/core.clj index b2ac355..6473a3e 100644 --- a/src/pricebot/core.clj +++ b/src/pricebot/core.clj @@ -183,15 +183,15 @@ (with-out-str (clojure.pprint/pprint o))) (defn get-args [keys args] - (let [input-opts (parse-opts args cli-opts) - opts (into {} (map (partial get-key input-opts) keys)) - missing (filter (fn [k] (not (get opts k))) keys)] - (cond (:help opts) (exit! 0 (:summary opts)) - (:errors opts) (exit! 1 (str/join \newline (:errors opts))) + (let [{:keys [options arguments errors summary]} (parse-opts args cli-opts) + resolved (into {} (map (partial get-key options) keys)) + missing (filter (fn [k] (not (get resolved k))) keys)] + (cond (:help options) (exit! 0 summary) + errors (exit! 1 (str/join \newline errors)) (not (empty? missing)) (exit! 2 (str "missing arguments: " (str/join " " (map name missing)) \newline "available: " (pprint-to-string opts))) - :else opts))) + :else resolved))) (defn -main [& args] (let [required-keys [:exchange-host