Skip to content

Commit

Permalink
Only the suggestions that have the same minimum distance.
Browse files Browse the repository at this point in the history
  • Loading branch information
joegallo committed Aug 8, 2012
1 parent 363d1c6 commit 5e2ff4e
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions leiningen-core/src/leiningen/core/main.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)
(println)
(println "Did you mean this?")
(doseq [suggestion suggestions]
(println " " suggestion))))
(when-let [suggestions (suggestions task)]
(println)
(println "Did you mean this?")
(doseq [suggestion suggestions]
(println " " suggestion)))
(abort))

;; TODO: got to be a cleaner way to do this, right?
Expand Down

0 comments on commit 5e2ff4e

Please sign in to comment.