Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/pokle/clojr

Run single file clojure scripts
https://github.com/pokle/clojr

Last synced: 10 days ago
JSON representation

Run single file clojure scripts

Awesome Lists containing this project

README

        

# Clojr

Clojr is short for Clojure runner.

I've always wanted to write single file utility Clojure scripts like you can with shell scripts, ruby, python, perl, etc. Now you can with Clojr.

### Installation - Unixes

Install [Java](http://java.sun.com), and if you use the repl a lot - install rlwrap (to get history and fancy editing).

```sh
git clone https://github.com/pokle/clojr
cd clojr
./scripts/build
./scripts/install
```

And then you should have clojr installed in /usr/local/bin/ - which should be on your path.

### Running

The first time your run clojr, it will download its Clojure dependencies.

#### Run your single file clojure scripts

clojr yourscript.clj

#### Run a REPL

clojr

#### Hash bangs!

Create a Clojure file starting with a has bang like this:

#!/usr/bin/env bash clojr
(println "Hellfjord - watch it!")

And if you called it hello.clj, you can make it executable and run it:

$ chmod +x hello.clj
$ ./hello.clj
Hellfjord - watch it!

#### Load adjacent files

Just use the Clojure load function to load other files in directories relative to the inital one. Have a look at the load_hello.clj sample.

#### Load maven / clojars dependencies

You can download maven or clojars libraries with the clojr/dep macro:

(clojr/dep cheshire) ; Loads the latest version of cheshire
(use 'cheshire.core) ; Bring it into our namespace
(parse-string "{}") ; => {}

You can specify a version like this:

(clojr/dep cheshire "5.3.1")

And roll in the '(use 'cheshire.core)' like this:

(clojr/dep cheshire "5.3.1" cheshire.core)

### Development

Read doc/building.md