Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Applying patch from Stuart Sierra for ticket

  • Loading branch information...
commit f9d92395cb788dd08cb144035a9d5fd8706d10b5 1 parent 74ff546
Gareth Jones authored
8 src/main/clojure/clojure/tools/cli.clj
View
@@ -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
8 src/test/clojure/clojure/tools/cli_test.clj
View
@@ -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"]}
Please sign in to comment.
Something went wrong with that request. Please try again.