Allow the user to select which reporter to use.
Add a dependency on tools.cli. Usage: lein kibit -r markdown
This commit is contained in:
parent
1227ba1fe4
commit
b2f6c8aa10
2 changed files with 13 additions and 8 deletions
|
@ -7,6 +7,7 @@
|
|||
:comments "Contact if any questions"}
|
||||
:dependencies [[org.clojure/clojure "1.5.0-beta1"]
|
||||
[org.clojure/core.logic "0.8.0-beta2"]
|
||||
[org.clojure/tools.namespace "0.2.1"]]
|
||||
[org.clojure/tools.namespace "0.2.1"]
|
||||
[org.clojure/tools.cli "0.2.2"]]
|
||||
:dev-dependencies [[lein-marginalia "0.7.0"]]
|
||||
:warn-on-reflection false)
|
||||
|
|
|
@ -2,17 +2,21 @@
|
|||
(:require [clojure.tools.namespace :refer [find-clojure-sources-in-dir]]
|
||||
[clojure.java.io :as io]
|
||||
[kibit.check :refer [check-file]]
|
||||
[kibit.reporters :refer [cli-reporter]]))
|
||||
[kibit.reporters :refer :all]
|
||||
[clojure.tools.cli :refer [cli]]))
|
||||
|
||||
(def cli-specs [["-r" "--reporter"
|
||||
"The reporter used when rendering suggestions"
|
||||
:default "text"]])
|
||||
|
||||
(defn run [project & args]
|
||||
(let [source-files (if (empty? args)
|
||||
(let [[options file-args usage-text] (apply (partial cli args) cli-specs)
|
||||
source-files (if (empty? file-args)
|
||||
(mapcat #(-> % io/file find-clojure-sources-in-dir)
|
||||
(or (:source-paths project) [(:source-path project)]))
|
||||
args)]
|
||||
file-args)]
|
||||
(doseq [file source-files]
|
||||
(try (->> (check-file file)
|
||||
(map cli-reporter)
|
||||
doall)
|
||||
(try (check-file file :reporter (name-to-reporter (:reporter options)))
|
||||
(catch Exception e
|
||||
(println "Check failed -- skipping rest of file")
|
||||
(println (.getMessage e)))))))
|
||||
(println (.getMessage e)))))))
|
||||
|
|
Loading…
Reference in a new issue