Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

allow the defdeps form to be prefixed with the #_ reader macro

  • Loading branch information...
commit 094471ef6672f1ded52e5c98377d9f7aa0c5c36b 1 parent 56a57ad
@tavisrudd authored
Showing with 15 additions and 8 deletions.
  1. +8 −5 README.md
  2. +1 −1  project.clj
  3. +6 −2 src/leiningen/oneoff.clj
View
13 README.md
@@ -23,9 +23,11 @@ you quickly want to analyse and plot some data using
## Usage
lein-oneoff scripts usually consist of a single file. Dependencies
-should be stated at the top using the `defdeps` form. Here's an example:
+should be stated at the top using the `defdeps` form. You may
+optionally prefix the `defdeps` form with the reader macro #_ (ignore
+next form). Here's an example:
- (defdeps
+ #_(defdeps
[[org.clojure/clojure "1.2.0"]
[compojure "0.5.2"]
[ring/ring-jetty-adapter "0.3.3"]])
@@ -60,9 +62,10 @@ signature:
where dependencies should be specified as a vector using the same
syntax as inside regular leiningen `defproject` form under the
`:dependencies` key. The second argument is an optional map of
-additional standard `defproject` entries. Please note that not
-all of the available leinigen options make sense for a one-off script
-and might not work correctly.
+additional standard `defproject` entries. Please note that not all of
+the available leinigen options make sense for a one-off script and
+might not work correctly. Adding a `#_` prefix will make it possible
+ignore the `defdeps` form when re-compiling the file in a repl.
One of the entries that can be useful is the `:repositories` entry. Here's
an example:
View
2  project.clj
@@ -1,4 +1,4 @@
-(defproject lein-oneoff "0.1.1"
+(defproject lein-oneoff "0.1.2"
:description "Dependency management for one-off scripts."
:dev-dependencies [[lein-clojars "0.6.0"]]
:eval-in-leiningen true)
View
8 src/leiningen/oneoff.clj
@@ -82,8 +82,12 @@ of a one-off project."
(when swank-form-var
(add-hook swank-form-var oneoff-swank-form-hook))
-(defn parse-defdeps [script]
- (let [form (read-string (slurp script))]
+(defn parse-defdeps
+ "Parse the defdeps form from the script, removing any leading #_
+ reader macro if needed."
+ [script]
+ (let [form (read-string
+ (.replaceFirst (re-matcher #"^ *#_" (slurp script)) ""))]
(if (= (first form) 'defdeps)
[(nth form 1) (nth form 2 {})]
[default-deps {}])))
Please sign in to comment.
Something went wrong with that request. Please try again.