← 返回命令列表

Linux command

clojure 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Start a Clojure REPL

clojure

Run a Clojure script

clojure -M [script.clj]

Execute a specific function

clojure -X [namespace/function]

Run with additional dependencies

clojure -Sdeps '{:deps {org.clojure/data.json {:mvn/version "2.4.0"}}}'

Start a REPL with a specific alias

clojure -A:[alias]

Evaluate an expression

clojure -M -e '(println "Hello, World!")'

Build an uberjar

clojure -T:build uber

Show classpath

clojure -Spath

说明

clojure is the official command-line launcher for the Clojure programming language. It manages dependencies through deps.edn configuration files and provides a streamlined workflow for REPL-driven development, script execution, and building applications. The CLI integrates with Maven and Git repositories for dependency resolution, automatically downloading and caching libraries as needed. Aliases in deps.edn allow defining different configurations for development, testing, and production environments. Clojure provides three main execution modes: -M for traditional main function execution, -X for executing functions with keyword arguments, and -T for tool invocation. The REPL supports interactive development with immediate feedback, a core practice in Clojure development.

参数

-M _:aliases_
Use concatenated aliases for running main entry point.
-X _:aliases_
Execute a function with exec arguments.
-T _:aliases_
Execute tool with exec arguments.
-A _:aliases_
Use concatenated aliases for REPL.
-Sdeps _EDN_
Additional dependencies in EDN format.
-Spath
Print the classpath and exit.
-Stree
Print the dependency tree.
-Sdescribe
Print environment and command info.
-e, --eval _STRING_
Evaluate the given expression.
-r, --repl
Run a REPL.
-h, --help
Display help information.

FAQ

What is the clojure command used for?

clojure is the official command-line launcher for the Clojure programming language. It manages dependencies through deps.edn configuration files and provides a streamlined workflow for REPL-driven development, script execution, and building applications. The CLI integrates with Maven and Git repositories for dependency resolution, automatically downloading and caching libraries as needed. Aliases in deps.edn allow defining different configurations for development, testing, and production environments. Clojure provides three main execution modes: -M for traditional main function execution, -X for executing functions with keyword arguments, and -T for tool invocation. The REPL supports interactive development with immediate feedback, a core practice in Clojure development.

How do I run a basic clojure example?

Run `clojure` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -M _:aliases_ do in clojure?

Use concatenated aliases for running main entry point.