-
Notifications
You must be signed in to change notification settings - Fork 85
Run
Simply enter lumo
at the command prompt to start up a Lumo REPL:
$ lumo
Lumo 1.8.0-beta
ClojureScript 1.9.927
Node.js v8.5.0
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Exit: Control+D or :cljs/quit or exit
cljs.user=>
If you are familiar with the standard Clojure REPL, this is much the same. You enter ClojureScript expressions, and they are evaulated, and the results printed.
Lumo can make use of ClojureScript libraries, making the code in such libraries available to your programs.
However, Lumo is not part of the Java ecosystem, the way Clojure is. Lumo does not run Java code, that means it can't directly access Maven artifacts on the internet, such as downloading ClojureScript JARs from Clojars 1. Additionally, Lumo uses the self-hosted, also known as bootstrap, flavor or the ClojureScript compiler.
The above means that not all the ClojureScript libraries are compatible with
lumo
. This is usually not a problem because of the vastity of the Node.js
ecosystem.
The classic example of this is andare
: a fork of core.async
specifically tailored for self-host ClojureScript.
It is not always easy to identify which library is compatible, check with the library author if unsure - the error message won't help you.
You can find a list of compatible libraries here.
The -c
(--classpath
) option is used to specify where to search for source
code as either directories, or packaged inside JAR files.
For example, if you have previously downloaded the
clojure/tools.cli
package, you can store it in a local project
folder and tell Lumo about it::
$ lumo -c src:lib/tools.cli-0.3.5.jar -m roll.dice --json 3d6
{"3d6": 17}
This adds the src
directory (presumably containing roll/dice.cljs
) and the
tools.cli
library to the classpath before running the roll.dice/-main
function. Our pretend tool rolls virtual dice and writes a JSON representation
of the results to standard out before exiting.
Keep in mind that any transitive dependencies are your responsibility: download
those to lib
as well, and add them to the command line.
Don't be afraid to add these libraries to version control: ClojureScript libraries tend to be quite small.
Lumo can also use artifacts in your local Maven repository (typically found at
$HOME/.m2
):
$ lumo -c src -D org.clojure/tools.cli:0.3.5 -m roll.dice --text 1d20
1d20: 5
This is not particularily more concise, and comes with the following caveats:
- The library must already be present in your local repository. Lumo will not download it.
- You must list any transitive dependencies, explicitly.
The ClojureScript libraries that have opted-in for npm
packaging and
publication won't require any additional step - just use yarn add
or npm install
and the files will be added to the classpath.
Note that this feature is still experimental and not thoroughly tested but it go a long way towards a more JS-orientend workflow.
1: understanding Maven artifacts, repositories, and third-party transitive dependencies is surprisingly complex. The only way to ensure accurate behavior is to use the underlying Java libraries. Lumo doesn't use Java and can't run those libraries.