You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/reference/clojure_cli.adoc
+25-9Lines changed: 25 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -46,29 +46,45 @@ Use this option to start a Clojure REPL.
46
46
clj [clj-opts] [-Aaliases]
47
47
----
48
48
49
-
To run a REPL, invoke `clj` without arguments:
49
+
To run a REPL, invoke `clj` without arguments.
50
+
51
+
This works in any directory, either with a deps.edn or not. If you are not in a <<clojure_cli#project_dir,project directory>>, the version of Clojure used will depend on the Clojure language version from the org.clojure dependency in the root deps.edn (will match the version number in CLI version number) or the user deps.edn in the <<clojure_cli#config_dir,config directory>> (usually not specified).
52
+
53
+
To supply <<clojure_cli#aliases,aliases>> that modify the <<clojure_cli#classpath,classpath>> or <<clojure_cli#jvm_props#,JVM properties>>, use `-A` with one or more concatenated alias keywords:
50
54
51
55
[source]
52
56
----
53
-
$ clj
54
-
Clojure 1.11.1
55
-
user=>
56
-
----
57
-
58
-
If you wish to include <<clojure_cli#aliases,aliases>> that affect the
57
+
clj -A:test
59
58
59
+
clj -A:test:dev
60
+
----
60
61
61
62
[[use_fn]]
62
63
=== Execute a function (-X)
63
64
64
-
Use the following exec-opt to invoke a function that takes a map:
65
+
The Clojure CLI can execute any function on the classpath that takes keyword args in a map as input.
`-X` is configured with an arg map with `:exec-fn` and `:exec-args` keys, and stored under an alias in `deps.edn`:
72
+
Function execution ultimately needs the following pieces of information:
73
+
74
+
* Classpath
75
+
* Qualified function to execute
76
+
* Map of key to value
77
+
78
+
79
+
80
+
`-X` <<clojure_cli#aliases,aliases>> can contain the following arg map keys:
81
+
82
+
* `:exec-fn` - a function symbol to use when none is supplied on the command line
83
+
* `:exec-args` - a map of key to value to include when `exec-fn` is executed, may be superseded by keyword args on the command line (so these act as defaults)
84
+
* `:ns-default` - default namespace symbol to use when interpreting the exec-fn
85
+
* `:ns-aliases` - map of alias symbol to namespace symbol to use when interpreting the exec-fn
0 commit comments