Skip to content

Commit

Permalink
removed reflection warnings (thanks to Michael Klishin) for pointing
Browse files Browse the repository at this point in the history
them out in the master branch.
  • Loading branch information
gar3thjon3s committed Oct 29, 2011
1 parent a012b65 commit 3c21359
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/main/clojure/clojure/tools/cli.clj
Expand Up @@ -4,6 +4,8 @@
[clojure.pprint :only (pprint cl-format)])
(:refer-clojure :exclude [replace]))

(set! *warn-on-reflection* true)

(defn build-doc [{:keys [switches docs default required]}]
[(apply str (interpose ", " switches))
(or (str default) "")
Expand All @@ -28,21 +30,25 @@
(defn name-for [k]
(replace k #"^--no-|^--\[no-\]|^--|^-" ""))

(defn flag-for [v]
(defn flag-for [^String v]
(not (.startsWith v "--no-")))

(defn opt? [x]
(defn opt? [^String x]
(.startsWith x "-"))

(defn flag? [x]
(defn flag? [^String x]
(.startsWith x "--[no-]"))

(defn end-of-args? [x]
(= "--" x))

(defn spec-for
[arg specs]
(first (filter #(.contains (% :switches) arg) specs)))
(->> specs
(filter (fn [s]
(let [switches (set (s :switches))]
(contains? switches arg))))
first))

(defn default-values-for
[specs]
Expand Down Expand Up @@ -79,7 +85,7 @@

(defn switches-for
[switches flag]
(-> (for [s switches]
(-> (for [^String s switches]
(cond
(and flag (flag? s)) [(replace s #"\[no-\]" "no-") (replace s #"\[no-\]" "")]
(and flag (.startsWith s "--")) [(replace s #"--" "--no-") s]
Expand Down

0 comments on commit 3c21359

Please sign in to comment.