Skip to content
This repository has been archived by the owner on Jul 18, 2020. It is now read-only.

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
technomancy committed Feb 28, 2012
0 parents commit 9fc1de6
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
@@ -0,0 +1,5 @@
pom.xml
*jar
/lib/
/classes/
.lein-deps-sum
16 changes: 16 additions & 0 deletions 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 changes: 3 additions & 0 deletions 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 changes: 17 additions & 0 deletions 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)))

0 comments on commit 9fc1de6

Please sign in to comment.