Git Product home page Git Product logo

inlein's Introduction

Inlein

Run Clojure scripts with dependencies, but without classpath pains.

Installation

For a full introduction and tutorial to Inlein, please see the Getting Started-page on the wiki. If you know how to use and install Leiningen, you can follow the installation steps and quickstarts in this README.

Inlein installs itself on the first run of the inlein script; there is no separate install script. Follow these instructions to install Inlein manually:

  1. Make sure you have a Java JDK version 7 or later.
  2. Download the latest inlein program released
  3. Place it on your $PATH. (~/bin is a good choice if it is on your path.)
  4. Set it to be executable. (chmod 755 ~/bin/inlein)
  5. Run it.

Note that the first invokation with a script may be a bit slow, as inlein has to retrieve and start the inlein daemon. You can force download and daemon startup by calling inlein --start-daemon, to ensure faster startup times on subsequent runs.

Quickstart

Inlein is usually called with the file to run, along with the parameters passed to the script itself.

inlein myscript.clj my args here

On *nix-like systems, you can omit calling inlein directly by making the script executable and prepending the shebang-line

#!/usr/bin/env inlein

at the very start of the script.

Sample Script

As an example, let's make a script which calculates the nth prime number for the user (0-indexed). We will use my prime library to find the prime, to show how to add dependencies.

Type this into a file, and call it primes.clj:

#!/usr/bin/env inlein

'{:dependencies [[org.clojure/clojure "1.8.0"]
                 [com.hypirion/primes "0.2.1"]]}

(require '[com.hypirion.primes :as p])

(when-not (first *command-line-args*)
  (println "Usage:" (System/getProperty "$0") "prime-number")
  (System/exit 1))

(-> (first *command-line-args*)
    (Long/parseLong)
    (p/get)
    println)

Now make it executable (chmod +x primes.clj), and try it out by e.g. calling ./primes.clj 10.

An inlein script begins with a quoted map, which contains the script's dependencies. They are specified exactly like in Leiningen, as a vector of dependencies associated with the :dependency key. The quoted map may also contain JVM options you want to set (generally to speed up program startup).

Inlein also tags the name of the file to the System property $0, to ease creation of "shell"-like scripts.

Building from Source

If you have ~/bin on your path and want to run a snapshot version of inlein, you can just call test/install.sh. This should place the client in ~/bin/inlein and the proper deamon where it needs to be placed. Remember that you have to override the installed inlein version manually if you want to upgrade or downgrade again.

To play around with the source, or install manually, see the Bootstrapping section in CONTRIBUTING.md.

License

Copyright © 2016 Jean Niklas L'orange

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version. See the file LICENSE.

inlein's People

Contributors

arrdem avatar bsvingen avatar hypirion avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.