This repository has been archived by the owner on Jul 18, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9fc1de6
Showing
4 changed files
with
41 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pom.xml | ||
*jar | ||
/lib/ | ||
/classes/ | ||
.lein-deps-sum |
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,16 @@ | ||
# lein-assoc | ||
|
||
A higher-order Leiningen task to run tasks with ad-hoc project keys. | ||
|
||
## Usage | ||
|
||
Put `lein-assoc` `"0.1.0"` into your `:user` profile or if you are on | ||
Leiningen 1.x do `lein plugin install lein-assoc 0.1.0`. | ||
|
||
$ lein assoc :warn-on-reflection true compile | ||
|
||
## License | ||
|
||
Copyright © 2012 Phil Hagelberg | ||
|
||
Distributed under the Eclipse Public License, the same as Clojure. |
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,3 @@ | ||
(defproject lein-assoc "0.1.0" | ||
:description "Leiningen plugin to run tasks with ad-hoc project keys." | ||
:eval-in-leiningen true) |
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,17 @@ | ||
(ns leiningen.assoc | ||
(:refer-clojure :exclude [assoc]) | ||
(:require [leiningen.core.main :as main])) | ||
|
||
(defn- classify-args [args] | ||
(loop [acc {:kvs []} | ||
[arg & args] args] | ||
(if (.startsWith arg ":") | ||
(recur (update-in acc [:kvs] conj (read-string arg) (first args)) | ||
(rest args)) | ||
(clojure.core/assoc acc :task arg :args args)))) | ||
|
||
(defn ^{:help-arglists '[(project key value task & args)]} assoc | ||
"Run a task with new entries assoc'd into the project map." | ||
[project & args] | ||
(let [{:keys [kvs task args]} (classify-args args)] | ||
(main/apply-task task (apply clojure.core/assoc project kvs) args))) |