Only the suggestions that have the same minimum distance.

This commit is contained in:
Joe Gallo 2012-08-08 09:22:51 -04:00
parent 363d1c61c2
commit 5e2ff4ebd3

View file

@ -89,19 +89,21 @@
(sort)))
(defn suggestions [task]
(for [t (tasks)
:let [n (.replaceAll (name t) "leiningen." "")]
:when (>= 3 (distance n task))]
n))
(let [suggestions (into {} (for [t (tasks)
:let [n (.replaceAll (name t)
"leiningen." "")]]
[n (distance n task)]))
min (apply min (vals suggestions))]
(when (<= min 4)
(map first (filter #(= min (second %)) suggestions)))))
(defn ^:no-project-needed task-not-found [task & _]
(println (str "'" task "' is not a task. See 'lein help'."))
(let [suggestions (suggestions task)]
(when (seq suggestions)
(when-let [suggestions (suggestions task)]
(println)
(println "Did you mean this?")
(doseq [suggestion suggestions]
(println " " suggestion))))
(println " " suggestion)))
(abort))
;; TODO: got to be a cleaner way to do this, right?