Permalink
Browse files

Refactor summarize for clarity

  • Loading branch information...
1 parent 2e44e94 commit b2ffe90b00e299dbcbaeb0c903409d50e64cbcd9 @guns guns committed Jan 2, 2014
Showing with 14 additions and 14 deletions.
  1. +7 −7 src/main/clojure/cljs/tools/cli.cljs
  2. +7 −7 src/main/clojure/clojure/tools/cli.clj
@@ -214,13 +214,13 @@
(defn summarize
"Reduce options specs into a options summary for printing at a terminal."
[specs]
- (let [show-defaults? (some #(and (:required %) (:default %)) specs)
- parts (map (partial make-summary-parts show-defaults?) specs)]
- (if (seq parts)
- (let [lens (apply map (fn [& cols] (apply max (map count cols))) parts)
- lines (format-lines lens parts)]
- (s/join \newline lines))
- "")))
+ (if (seq specs)
+ (let [show-defaults? (some #(and (:required %) (:default %)) specs)
+ parts (map (partial make-summary-parts show-defaults?) specs)
+ lens (apply map (fn [& cols] (apply max (map count cols))) parts)
+ lines (format-lines lens parts)]
+ (s/join \newline lines))
+ ""))
(defn- required-arguments [specs]
(reduce
@@ -370,13 +370,13 @@
(defn ^{:added "0.3.0"} summarize
"Reduce options specs into a options summary for printing at a terminal."
[specs]
- (let [show-defaults? (some #(and (:required %) (:default %)) specs)
- parts (map (partial make-summary-parts show-defaults?) specs)]
- (if (seq parts)
- (let [lens (apply map (fn [& cols] (apply max (map count cols))) parts)
- lines (format-lines lens parts)]
- (s/join \newline lines))
- "")))
+ (if (seq specs)
+ (let [show-defaults? (some #(and (:required %) (:default %)) specs)
+ parts (map (partial make-summary-parts show-defaults?) specs)
+ lens (apply map (fn [& cols] (apply max (map count cols))) parts)
+ lines (format-lines lens parts)]
+ (s/join \newline lines))
+ ""))
(defn- required-arguments [specs]
(reduce

0 comments on commit b2ffe90

Please sign in to comment.