A Brief Beginner's Guide To Clojure
← prev | next →     Top-level ToC     /standalone-scripts.html     (printable version)

For simple programs, you might forego creating a project for them and instead put everything needed into a single Clojure sourcecode file (a standalone “script”, like a Python or Perl script). These scripts can be run with help from the inlein tool.

Please note that this chapter has nothing to do with Clojurescript, which is a Clojure-to-Javascript compiler.

Just download and install inlein, then make a my-script.clj file containing something like:

#!/usr/bin/env inlein

'{:dependencies [[org.clojure/clojure "1.8.0"]
                 [cool-stuff/such-and-such "1.2.3"]]}

(require '[clojure.whatever :as whtv]
         '[cool-stuff.something :as sth])

(println "Hi! You passed:" *command-line-args*)

Make it executable (chmod +x my-script.clj) and run it in the usual way:

my-script.clj foo bar baz