Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial commit.

  • Loading branch information...
commit 9fc1de643a0d297bf7b390933e79d4d2fe65f875 0 parents
@technomancy authored
Showing with 41 additions and 0 deletions.
  1. +5 −0 .gitignore
  2. +16 −0 README.md
  3. +3 −0  project.clj
  4. +17 −0 src/leiningen/assoc.clj
5 .gitignore
@@ -0,0 +1,5 @@
+pom.xml
+*jar
+/lib/
+/classes/
+.lein-deps-sum
16 README.md
@@ -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.
3  project.clj
@@ -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)
17 src/leiningen/assoc.clj
@@ -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)))
Please sign in to comment.
Something went wrong with that request. Please try again.