Skip to content
Permalink
Browse files

Applying patch from Stuart Sierra for ticket

  • Loading branch information...
Gareth Jones
Gareth Jones committed Aug 8, 2012
1 parent 74ff546 commit f9d92395cb788dd08cb144035a9d5fd8706d10b5
Showing with 13 additions and 3 deletions.
  1. +6 −2 src/main/clojure/clojure/tools/cli.clj
  2. +7 −1 src/test/clojure/clojure/tools/cli_test.clj
@@ -49,7 +49,11 @@

(defn- default-values-for
[specs]
(into {} (for [s specs] [(s :name) (s :default)])))
(reduce (fn [m s]
(if (contains? s :default)
(assoc m (:name s) (:default s))
m))
{} specs))

(defn- apply-specs
[specs args]
@@ -101,8 +105,8 @@
:aliases (set aliases)
:name (keyword (last aliases))
:parse-fn identity
:default (if flag false nil)
:flag flag}
(when flag {:default false})
options)))

(defn cli
@@ -34,7 +34,13 @@
(deftest should-override-when-supplied
(is (= {:server "127.0.0.1"}
(first (cli ["--server" "127.0.0.1"]
["--server" :default "10.0.1.10"]))))))
["--server" :default "10.0.1.10"])))))
(deftest should-omit-key-when-no-default
(is (= false
(contains? (cli ["--server" "127.0.0.1"]
["--server" :default "10.0.1.10"]
["--names"])
:server)))))

(deftest should-apply-parse-fn
(is (= {:names ["john" "jeff" "steve"]}

0 comments on commit f9d9239

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