Skip to content

Commit d47a05c

Browse files
committed
create option index
1 parent d9042c1 commit d47a05c

File tree

1 file changed

+67
-34
lines changed

1 file changed

+67
-34
lines changed

content/reference/clojure_cli.adoc

Lines changed: 67 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,70 @@ The Clojure CLI is a command-line tool to run Clojure programs on the Java Virtu
1515

1616
== Installation
1717

18-
The Clojure CLI can be installed via Homebrew, bash/posix script, or Powershell depending on the platform. See the <<xref/../../../guides/install_clojure#,installation guide>> for details and the <<xref/../../../releases/tools#,release page>> for version information. You can also read the <<xref/../../../guides/deps_and_cli#,guide>> for a longer tutorial.
18+
The Clojure CLI can be installed via Homebrew, bash/posix script, or Powershell depending on the platform. See the <<xref/../../../guides/install_clojure#,installation guide>> for details and the <<xref/../../../releases/tools#,release page>> for version information. You can also read the <<xref/../../../guides/deps_and_cli#,guide>> for a longer tutorial. For artifact building, check out the <<xref/../../../guides/tools_build#,tools.build guide>>.
1919

2020
Any version of the Clojure CLI can use any version of the Clojure language. Generally it is best to use the latest <<xref/../../../releases/tools#,version of the CLI>> to have the latest features and fixes. Given a CLI version A.B.C[.D], the default <<xref/../../../releases/downloads#,version of Clojure>> used at the REPL will be A.B.C, however you can specify an older (or newer!) version of the language in your dependencies.
2121

2222
[[usage]]
2323
== Usage
2424

25-
The CLI is invoked via either `clojure` or `clj`. In general, you can treat these interchangeably, but `clj` includes `rlwrap` for extended keyboard editing, of particular use for the REPL. Because `clj` is fewer characters to type, it is most commonly used but this reference will use `clj` for REPL examples and `clojure` for non-REPL examples.
25+
The CLI is invoked via either `clojure` or `clj`. In general, you can treat these interchangeably but `clj` includes `rlwrap` for extended keyboard editing, particularly useful with the REPL. This reference uses `clj` for REPL examples and `clojure` for non-REPL examples.
26+
27+
Each execution of the Clojure CLI runs a Clojure program by determining all paths, dependencies, and main entry point, then invoking the program on the JVM. The primary kind of execution is determined by `-X`, `-T`, and `-M` (or their absence). Configuration is defined by one or more <<deps_edn,deps.edn>> files in combination with the <<clojure_cli#opt_index,command-line options>>.
28+
29+
[[commands]]
30+
=== Primary commands
31+
32+
<<clojure_cli#use_repl,Start a REPL:>> +
33+
`clj [clj-opts] [-Aaliases]`
34+
35+
<<clojure_clj#use_fn,Execute a function:>> +
36+
`clojure [clj-opts] -X[aliases] my/fn? [kpath v ...] kv-map?`
37+
38+
<<clojure_clj#use_tool,Run a tool:>> +
39+
`clojure [clj-opts] -T[name|aliases] my/fn [kpath v ...] kv-map?`
40+
41+
<<clojure_clj#use_main,Run a main namespace or script:>> +
42+
`clojure [clj-opts] -M[aliases] [init-opts] [main-opts] [args]`
43+
44+
[[options]]
45+
=== Option index:
2646

2747
[subs=+macros]
2848
----
29-
<<clojure_cli#use_repl,clj [clj-opts] [-Aaliases]>>
30-
<<clojure_clj#use_fn,clojure [clj-opts] -X[aliases] my/fn? [kpath v ...] kv-map?>>
31-
<<clojure_clj#use_tool,clojure [clj-opts] -T[name|aliases] my/fn [kpath v ...] kv-map?>>
32-
<<clojure_clj#use_main,clojure [clj-opts] -M[aliases] [init-opts] [main-opts] [args]>>
33-
34-
See the <<clojure_cli#opt_index,option index>> for a complete list of CLI options.
49+
exec-opts:
50+
<<clojure_cli#opt_a,-Aaliases>> Use aliases, particularly for repl execution
51+
<<clojure_cli#opt_x,-X[aliases]>> Invoke function, using aliases
52+
<<clojure_cli#opt_t,-Ttoolname>> Invoke tool by local name
53+
<<clojure_cli#opt_t,-T[aliases]>> Invoke tool by concatenated aliases (ala -X)
54+
<<clojure_cli#opt_m,-M[aliases]>> Invoke clojure.main, using aliases
55+
<<clojure_cli#opt_p,-P>> Prepare deps but don't exec
56+
57+
clj-opts:
58+
<<clojure_cli#opt_j,-Jopt>> Pass opt through in java_opts, ex: -J-Xmx512m
59+
<<clojure_cli#opt_sdeps,-Sdeps EDN>> Extra deps.edn data
60+
<<clojure_cli#opt_srepro,-Srepro>> Ignore user deps.edn file
61+
<<clojure_cli#opt_spath,-Spath>> Compute classpath, echo to stdout
62+
<<clojure_cli#opt_stree,-Stree>> Print dependency tree
63+
<<clojure_cli#opt_scp,-Scp CP>> Use this classpath instead of computing
64+
<<clojure_cli#opt_sforce,-Sforce>> Force recomputation of the classpath
65+
<<clojure_cli#opt_sverbose,-Sverbose>> Print important path info to console
66+
<<clojure_cli#opt_sdescribe,-Sdescribe>> Print environment and command parsing info as data
67+
<<clojure_cli#opt_sthreads,-Sthreads>> Set specific number of download threads
68+
<<clojure_cli#opt_strace,-Strace>> Write a trace.edn file that traces deps expansion
69+
<<clojure_cli#opt_sversion,--version>> Print the version to stdout and exit
70+
<<clojure_cli#opt_sversion,-version>> Print the version to stderr and exit
71+
<<clojure_cli#opt_help,--help -h -?>> Print this help message and exit
72+
73+
Programs provided by :deps alias:
74+
<<clojure_cli#deps_list,-X:deps list>> List transitive deps + licenses
75+
<<clojure_cli#deps_tree,-X:deps tree>> Print deps tree
76+
<<clojure_cli#deps_find_versions,-X:deps find-versions>> Find available versions of library
77+
<<clojure_cli#deps_prep,-X:deps prep>> Prepare all unprepped libs in dep tree
78+
<<clojure_cli#deps_mvn_pom,-X:deps mvn-pom>> Generate pom.xml for deps.edn
79+
<<clojure_cli#deps_mvn_install,-X:deps mvn-install>> Install maven jar to local repo
3580
----
3681

37-
Each execution of the Clojure CLI runs a Clojure program by determining all paths, dependencies, and main entry point, then invoking the program on the JVM. The primary kind of execution is determined by `-X`, `-T`, and `-M` (or their absence), described further below. Configuration is defined by one or more <<deps_edn,deps.edn>> files in combination with the command-line options.
38-
3982
[[use_repl]]
4083
=== Start a REPL
4184

@@ -157,6 +200,20 @@ clojure [clj-opt*] -M[aliases] [main-opts]
157200

158201
The -M aliases are pulled from `deps.edn` and combined to form an arg map. The arg map can modify the classpath or supply main options.
159202

203+
[subs=+macros]
204+
----
205+
__init-opts: (use with -M only)__
206+
-i, --init path Load a file or resource
207+
-e, --eval string Eval exprs in string; print non-nil values
208+
--report target Report uncaught exception to "file" (default), "stderr", or "none"
209+
210+
__main-opts:__
211+
-m, --main ns-name Call the -main function from namespace w/args
212+
-r, --repl Run a repl
213+
path Run a script from a file or resource
214+
- Run a script from standard input
215+
----
216+
160217
See the <<repl_and_main#,clojure.main>> documentation for more details on main options.
161218

162219
[[aliases]]
@@ -252,30 +309,6 @@ PS D:> clj -X clojure.core/prn :val '{:s1 """nospaces""" :s2 ""has spaces""}'
252309
{:val {:s1 "nospaces", :s2 "has spaces"}}
253310
----
254311

255-
[[opt_index]]
256-
== Option index
257-
258-
opt_A
259-
opt_X
260-
opt_T
261-
opt_M
262-
opt_fn
263-
opt_kvs
264-
opt_main_init
265-
opt_main_opt
266-
opt_help
267-
opt_version
268-
opt_J
269-
opt_sdeps
270-
opt_spath
271-
opt_stree
272-
opt_scp
273-
opt_srepro
274-
opt_sforce
275-
opt_strace
276-
opt_sthreads
277-
opt_sverbose
278-
279312
[[procurers]]
280313
= Procurers
281314

0 commit comments

Comments
 (0)