/
bikeshed.clj
49 lines (47 loc) · 1.74 KB
/
bikeshed.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
(ns leiningen.bikeshed
(:require [clojure.string :as str]
[clojure.tools.cli :as cli]
[leiningen.core.eval :as lein]
[leiningen.core.project :as project]))
(defn help
"Help text displayed from the command line"
[]
"Bikesheds your project with totally arbitrary criteria.")
(defn bikeshed
"Main function called from Leiningen"
[project & args]
(let [[opts args banner]
(cli/cli
args
["-H" "--help-me" "Show help"
:flag true :default false]
["-v" "--verbose" "Display missing doc strings"
:flag true :default false]
["-m" "--max-line-length" "Max line length"
:default nil
:parse-fn #(Integer/parseInt %)]
["-x" "--exclude-profiles" "Comma-separated profile exclusions"
:default nil
:parse-fn #(mapv keyword (str/split % #","))])
lein-opts (:bikeshed project)
project (if-let [exclusions (seq (:exclude-profiles opts))]
(-> project
(project/unmerge-profiles exclusions)
(update-in [:profiles] #(apply dissoc % exclusions)))
project)]
(if (:help-me opts)
(println banner)
(lein/eval-in-project
(-> project
(update-in [:dependencies]
conj
['lein-bikeshed "0.4.1"]))
`(if (bikeshed.core/bikeshed
'~project
{:max-line-length (or (:max-line-length ~opts)
(:max-line-length ~lein-opts))
:verbose (:verbose ~opts)}
(select-keys ~opts [:max-line-length :verbose]))
(System/exit -1)
(System/exit 0))
'(require 'bikeshed.core)))))