brentonashworth/one — Issue #92: Add lein script task
Author: candera
Created: 2012-01-26 15:59:57+00:00
State: open

## Background

Right now, to run things in the context of the project (as opposed to the context of `lein` itself) you have to do things like `lein run -m script.build`. While that's not too bad, it would be slightly nicer if that were `lein build` or even `lein script build`.

As it turns out, it wouldn't be hard at all to provide either (or both) of those options. We could add a `lein script` task that could call anything in the context of the project simply by delegating to `lein run`.

## Acceptance Criteria

* A `lein script` task is added
* `lein run -m script.build`, `lein run -m script.serve`, and `lein run -m script.docs` are replaced by `lein script build`, `lein script serve`, and `lein script docs`, respectively.

## Tech Notes

### A simple prototype

```clj
(ns leiningen.script
(:require leiningen.run))

(defn script [project script & args]
(println "Running script" script "with arguments" args)
(apply leiningen.run/run project "-m" (str "script." script) args))
```

And then, e.g., if you ran `lein script foo`, it would invoke the `-main` function in the `script.foo` namespace **in the context of the project**.