-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Working on lein plugin, broken by verify error so far
- Loading branch information
Showing
4 changed files
with
51 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
(ns leiningen.cloc | ||
"Leiningen plugin to start the cloc web server locally." | ||
(:require [leiningen.core.classpath :as cp] | ||
[cemerick.pomegranate.aether :as aether] | ||
[cloc.core :refer [main]])) | ||
|
||
(defn- try-parse | ||
"Try to convert v to integer, then bool, else string." | ||
[v] | ||
(if-let [num (try (Integer/parseInt v) (catch NumberFormatException _ nil))] | ||
num | ||
(cond | ||
(re-find #"true|flase" (.toLowerCase v)) (Boolean/parseBoolean v) | ||
:else (str v)))) | ||
|
||
(defn cloc | ||
"Start the cloc doc server locally, serving API docs for | ||
your code and all your dependencies. Accepts ring configuration | ||
map keyword and value arguments. Most useful ones will be: | ||
- :host -- host name to listen on | ||
- :port -- port to listen for connections on" | ||
[project & args] | ||
(let [jars (filter (fn [f] (re-find #"\.jar$") (.getName f)) | ||
(aether/dependency-files | ||
(cp/dependency-hierarchy :dependencies project)))] | ||
(assert (even? (count args)) | ||
"Number of args should be even - only key-value pairs supported.") | ||
(main (merge | ||
(reduce (fn [m [k v ]] (assoc m (keyword k) (try-parse v))) | ||
{} | ||
(partition 2 args)) | ||
{:join? true})))) |