LinuxCommandLibrary

clj

Clojure tool to start a REPL or invoke a specific function with data.

TLDR

Start a REPL (interactive shell)

$ clj
copy


Execute a function
$ clj -X [namespace/function_name]
copy


Run the main function of a specified namespace
$ clj -M -m [namespace] [args]
copy


Prepare a project by resolving dependencies, downloading libraries, and making/caching classpaths
$ clj -P
copy


Start an nREPL server with the CIDER middleware
$ clj -Sdeps '{:deps {nrepl {:mvn/version "0.7.0"} cider/cider-nrepl {:mvn/version "0.25.2"]}' -m nrepl.cmdline --middleware '["cider.nrepl/cider-middleware"]' --interactive
copy


Start a REPL for ClojureScript and open a web browser
$ clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.758"]}' --main cljs.main --repl
copy

SYNOPSIS

clj [clj-opts] [-Aaliases] [init-opts]
clojure [clj-opts] -X[aliases] my/fn? [kpath v ...] kv-map?
clojure [clj-opts] -T[name|aliases] my/fn [kpath v ...] kv-map?
clojure [clj-opts] -M[aliases] [init-opts] [main-opts] [args]

DESCRIPTION

The clojure tool is a runner for Clojure programs. clj is a wrapper for clojure that uses rlwrap to provide a better interactive experience. Users will typically run clj.

EXAMPLES

You can launch a Clojure REPL by running clj.

See the Deps and CLI Guide below for more complex usage.

OPTIONS

The clj and clojure scripts can take three types of options, as shown in the synopsis. clj-opts are used to build the java-opts and classpath. init-opts refer to Clojure code to execute. main-opts are options to clojure.main.

clj-opts

-Jopt

Pass opt through in java_opts, ex: -J-Xmx512m

-Aaliases

Concatenated aliases for REPL execution, ex: -A:dev:mem

-Xaliases fn KPATH V

Exec alias to invoke one or more functions that take a map, with keypath/value overrides. Function must either be supplied or be in :exec-fn argmap for alias

-Maliases

Exec clojure.main, either from opts in alias or command line

-P

Prepare - download libs, cache classpath without executing

-Sdeps EDN

Deps data to use as the last deps file to be merged

-Spath

Compute classpath and echo to stdout only

-Scp CP

Do NOT compute or cache classpath, use this one instead

-Srepro

Ignore the ~/.clojure/deps.edn config file

-Sforce

Force recomputation of the classpath (don't use the cache)

-Sverbose

Print important path info to console

-Sdescribe

Print environment and command parsing info as data

-Sthreads N

Set specific number of download threads

-Strace

Write a trace.edn file that traces deps expansion

--

Stop parsing dep options and pass remaining arguments to clojure.main

--version

Write version to stdout and exit

-version

Write version to stderr and exit

init-opts

-i, --init path

Load a file or resource located at path

-e, --eval string

Eval exprs in string; print non-nil values

--report target

Report uncaught exception to target: "file" (default), "stderr", or "none", overrides System property clojure.main.report

main-opts

-m, --main ns-name

Call the -main function from namespace w/args

-r, --repl

Run a repl

path

Run a script from a file or resource located at path

-

Run a script from standard input

-h, -?, --help

Print this help message and exit

CONFIGURATION

This script reads configuration from deps.edn files. It will check against deps.edn files in the system root location, the user configuration directory (usually ~/.clojure), and the local directory. Files in each of these locations, if they exist, are merged to form one combined configuration file. The last specified configuration file's options overwrites any earlier files (e.g. local configs take priority).

BUGS

File issues at https://ask.clojure.org under category Libs / tools.deps.alpha.

AUTHORS

clojure and clj are maintained by Alex Miller <alex.miller@cognitect.com>. This man page was written by Elana Hashman <ehashman@debian.org>.

COPYRIGHT

Copyright © 2018-2020 Rich Hickey, Alex Miller and contributors.

Distributed under the Eclipse Public License 1.0, the same as Clojure.

SEE ALSO

https://clojure.org/guides/deps_and_cli Deps and CLI Guide https://clojure.org/reference/deps_and_cli Deps and CLI Reference https://clojure.org/reference/repl_and_main REPL and Main Entrypoints https://github.com/clojure/brew-install/blob/1.10.3/CHANGELOG.md Changelog for scripts https://github.com/clojure/tools.deps.alpha/blob/master/CHANGELOG.md Changelog for tools.deps library

Copied to clipboard