11# Table of contents
2- - [ ` babashka.cli ` ] ( #babashkacli )
3- - [ ` auto-coerce ` ] ( #auto-coerce ) - Auto-coerces <code >s</code > to data
4- - [ ` coerce ` ] ( #coerce ) - Coerce string <code >s</code > using <code >f</code >
5- - [ ` dispatch ` ] ( #dispatch ) - Subcommand dispatcher.
6- - [ ` format-opts ` ] ( #format-opts )
7- - [ ` format-table ` ] ( #format-table )
8- - [ ` merge-opts ` ] ( #merge-opts ) - Merges babashka CLI options.
9- - [ ` number-char? ` ] ( #number-char? )
10- - [ ` opts->table ` ] ( #opts->table )
11- - [ ` pad ` ] ( #pad )
12- - [ ` pad-cells ` ] ( #pad-cells )
13- - [ ` parse-args ` ] ( #parse-args ) - Same as <code >parse-opts</code > but separates parsed opts into <code >: opts </code > and adds
14- - [ ` parse-cmds ` ] ( #parse-cmds ) - Parses sub-commands (arguments not starting with an option prefix) and returns a
15- - [ ` parse-keyword ` ] ( #parse-keyword ) - Parse keyword from <code >s</code >
16- - [ ` parse-opts ` ] ( #parse-opts ) - Parse the command line arguments <code >args</code >, a seq of strings.
17- - [ ` rows ` ] ( #rows )
18- - [ ` spec->opts ` ] ( #spec->opts ) - Converts spec into opts format
19- - [ ` babashka.cli.exec ` ] ( #babashkacliexec )
20- - [ ` -main ` ] ( #-main ) - Main entrypoint for command line usage.
21- - [ ` main ` ] ( #main )
22- # babashka.cli
23-
24-
25-
26-
27-
28- ## ` auto-coerce `
29- ``` clojure
2+ - [ ` babashka.cli ` ] ( #babashka.cli )
3+ - [ ` auto-coerce ` ] ( #babashka.cli/auto-coerce ) - Auto-coerces <code >s</code > to data.
4+ - [ ` coerce ` ] ( #babashka.cli/coerce ) - Coerce string <code >s</code > using <code >f</code >.
5+ - [ ` dispatch ` ] ( #babashka.cli/dispatch ) - Subcommand dispatcher.
6+ - [ ` format-opts ` ] ( #babashka.cli/format-opts )
7+ - [ ` format-table ` ] ( #babashka.cli/format-table )
8+ - [ ` merge-opts ` ] ( #babashka.cli/merge-opts ) - Merges babashka CLI options.
9+ - [ ` number-char? ` ] ( #babashka.cli/number-char? )
10+ - [ ` opts->table ` ] ( #babashka.cli/opts->table )
11+ - [ ` pad ` ] ( #babashka.cli/pad )
12+ - [ ` pad-cells ` ] ( #babashka.cli/pad-cells )
13+ - [ ` parse-args ` ] ( #babashka.cli/parse-args ) - Same as [ <code >parse-opts</code >] ( #babashka.cli/parse-opts ) but separates parsed opts into <code >: opts </code > and adds <code >: cmds </code > and <code >: rest-args </code > on the top level instead of metadata.
14+ - [ ` parse-cmds ` ] ( #babashka.cli/parse-cmds ) - Parses sub-commands (arguments not starting with an option prefix) and returns a map with: * <code >: cmds </code > - The parsed subcommands * <code >: args </code > - The remaining (unparsed) arguments.
15+ - [ ` parse-keyword ` ] ( #babashka.cli/parse-keyword ) - Parse keyword from <code >s</code >.
16+ - [ ` parse-opts ` ] ( #babashka.cli/parse-opts ) - Parse the command line arguments <code >args</code >, a seq of strings.
17+ - [ ` spec->opts ` ] ( #babashka.cli/spec->opts ) - Converts spec into opts format.
18+ - [ ` babashka.cli.exec ` ] ( #babashka.cli.exec )
19+ - [ ` -main ` ] ( #babashka.cli.exec/-main ) - Main entrypoint for command line usage.
20+ - [ ` main ` ] ( #babashka.cli.exec/main )
21+
22+ -----
23+ # <a name =" babashka.cli " >babashka.cli</a >
24+
25+
26+
27+
3028
29+
30+ ## <a name =" babashka.cli/auto-coerce " >` auto-coerce ` </a >
31+ ``` clojure
3132(auto-coerce s)
3233```
33-
34+ Function.
3435
3536Auto-coerces ` s ` to data. Does not coerce when ` s ` is not a string.
3637 If ` s ` :
3738 * is ` true ` or ` false ` , it is coerced as boolean
38- * starts with number, it is coerced as a number (through ` edn/read-string ` )
39- * starts with ` : ` , it is coerced as a keyword (through ` parse-keyword ` )
40- <br ><sub >[ source] ( https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L77-L103 ) </sub >
41- ## ` coerce `
42- ``` clojure
39+ * starts with number, it is coerced as a number (through Clojure's ` edn/read-string ` )
40+ * starts with ` : ` , it is coerced as a keyword (through [ ` parse-keyword ` ] ( #babashka.cli/parse-keyword ) )
41+ <p ><sub ><a href =" https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L77-L103 " >Source</a ></sub ></p >
4342
43+ ## <a name =" babashka.cli/coerce " >` coerce ` </a >
44+ ``` clojure
4445(coerce s f)
4546```
46-
47+ Function.
4748
4849Coerce string ` s ` using ` f ` . Does not coerce when ` s ` is not a string.
4950 ` f ` may be a keyword (` :boolean ` , ` :int ` , ` :double ` , ` :symbol ` ,
5051 ` :keyword ` ) or a function. When ` f ` return ` nil ` , this is
5152 interpreted as a parse failure and throws.
52- <br ><sub >[ source] ( https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L143-L149 ) </sub >
53- ## ` dispatch `
54- ``` clojure
53+ <p ><sub ><a href =" https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L143-L149 " >Source</a ></sub ></p >
5554
55+ ## <a name =" babashka.cli/dispatch " >` dispatch ` </a >
56+ ``` clojure
5657(dispatch table args)
5758(dispatch table args opts)
5859```
59-
60+ Function.
6061
6162Subcommand dispatcher.
6263
@@ -72,7 +73,7 @@ Subcommand dispatcher.
7273 ```
7374
7475 When a match is found, ` :fn ` called with the return value of
75- [ ` parse-args ` ] ( #parse-args ) applied to ` args ` enhanced with:
76+ [ ` parse-args ` ] ( #babashka.cli/ parse-args ) applied to ` args ` enhanced with:
7677
7778 * ` :dispatch ` - the matching commands
7879 * ` :args ` - concatenation of unparsed commands and args
@@ -82,100 +83,100 @@ Subcommand dispatcher.
8283
8384 Provide an ` :error-fn ` to deal with non-matches.
8485
85- Each entry in the table may have additional [ ` parse-args ` ] ( #parse-args ) options.
86+ Each entry in the table may have additional [ ` parse-args ` ] ( #babashka.cli/ parse-args ) options.
8687
8788 For more information and examples, see [ README.md] ( README.md#subcommands ) .
88- <br ><sub >[ source] ( https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L729-L761 ) </sub >
89- ## ` format-opts `
90- ``` clojure
89+ <p ><sub ><a href =" https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L729-L761 " >Source</a ></sub ></p >
9190
91+ ## <a name =" babashka.cli/format-opts " >` format-opts ` </a >
92+ ``` clojure
9293(format-opts {:as cfg, :keys [indent], :or {indent 2 }})
9394```
95+ Function.
96+ <p ><sub ><a href =" https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L628-L632 " >Source</a ></sub ></p >
9497
95- <sub >[ source] ( https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L628-L632 ) </sub >
96- ## ` format-table `
98+ ## <a name =" babashka.cli/format-table " >` format-table ` </a >
9799``` clojure
98-
99100(format-table {:keys [rows indent], :or {indent 2 }})
100101```
102+ Function.
103+ <p ><sub ><a href =" https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L566-L579 " >Source</a ></sub ></p >
101104
102- <sub >[ source] ( https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L566-L579 ) </sub >
103- ## ` merge-opts `
105+ ## <a name =" babashka.cli/merge-opts " >` merge-opts ` </a >
104106``` clojure
105-
106107(merge-opts m & ms)
107108```
108-
109+ Function.
109110
110111Merges babashka CLI options.
111- <br ><sub >[ source] ( https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L12-L15 ) </sub >
112- ## ` number-char? `
113- ``` clojure
112+ <p ><sub ><a href =" https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L12-L15 " >Source</a ></sub ></p >
114113
114+ ## <a name =" babashka.cli/number-char? " >` number-char? ` </a >
115+ ``` clojure
115116(number-char? c)
116117```
118+ Function.
119+ <p ><sub ><a href =" https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L53-L55 " >Source</a ></sub ></p >
117120
118- <sub >[ source] ( https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L53-L55 ) </sub >
119- ## ` opts->table `
121+ ## <a name =" babashka.cli/opts->table " >` opts->table ` </a >
120122``` clojure
121-
122123(opts->table {:keys [spec order]})
123124```
125+ Function.
126+ <p ><sub ><a href =" https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L609-L626 " >Source</a ></sub ></p >
124127
125- <sub >[ source] ( https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L609-L626 ) </sub >
126- ## ` pad `
128+ ## <a name =" babashka.cli/pad " >` pad ` </a >
127129``` clojure
128-
129130(pad len s)
130131```
132+ Function.
133+ <p ><sub ><a href =" https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L544-L544 " >Source</a ></sub ></p >
131134
132- <sub >[ source] ( https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L544-L544 ) </sub >
133- ## ` pad-cells `
135+ ## <a name =" babashka.cli/pad-cells " >` pad-cells ` </a >
134136``` clojure
135-
136137(pad-cells rows)
137138```
139+ Function.
140+ <p ><sub ><a href =" https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L546-L552 " >Source</a ></sub ></p >
138141
139- <sub >[ source] ( https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L546-L552 ) </sub >
140- ## ` parse-args `
142+ ## <a name =" babashka.cli/parse-args " >` parse-args ` </a >
141143``` clojure
142-
143144(parse-args args)
144145(parse-args args opts)
145146```
147+ Function.
146148
147-
148- Same as [ ` parse-opts ` ] ( #parse-opts ) but separates parsed opts into ` :opts ` and adds
149+ Same as [ ` parse-opts ` ] ( #babashka.cli/parse-opts ) but separates parsed opts into ` :opts ` and adds
149150 ` :cmds ` and ` :rest-args ` on the top level instead of metadata.
150- <br ><sub >[ source] ( https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L515-L522 ) </sub >
151- ## ` parse-cmds `
152- ``` clojure
151+ <p ><sub ><a href =" https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L515-L522 " >Source</a ></sub ></p >
153152
153+ ## <a name =" babashka.cli/parse-cmds " >` parse-cmds ` </a >
154+ ``` clojure
154155(parse-cmds args)
155156(parse-cmds args {:keys [no-keyword-opts]})
156157```
157-
158+ Function.
158159
159160Parses sub-commands (arguments not starting with an option prefix) and returns a map with:
160161 * ` :cmds ` - The parsed subcommands
161162 * ` :args ` - The remaining (unparsed) arguments
162- <br ><sub >[ source] ( https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L207-L217 ) </sub >
163- ## ` parse-keyword `
164- ``` clojure
163+ <p ><sub ><a href =" https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L207-L217 " >Source</a ></sub ></p >
165164
165+ ## <a name =" babashka.cli/parse-keyword " >` parse-keyword ` </a >
166+ ``` clojure
166167(parse-keyword s)
167168```
168-
169+ Function.
169170
170171Parse keyword from ` s ` . Ignores leading ` : ` .
171- <br ><sub >[ source] ( https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L65-L70 ) </sub >
172- ## ` parse-opts `
173- ``` clojure
172+ <p ><sub ><a href =" https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L65-L70 " >Source</a ></sub ></p >
174173
174+ ## <a name =" babashka.cli/parse-opts " >` parse-opts ` </a >
175+ ``` clojure
175176(parse-opts args)
176177(parse-opts args opts)
177178```
178-
179+ Function.
179180
180181Parse the command line arguments ` args ` , a seq of strings.
181182 Instead of a leading ` : ` either ` -- ` or ` - ` may be used as well.
@@ -209,31 +210,31 @@ Parse the command line arguments `args`, a seq of strings.
209210 ; ; => throws 'Unknown option --qux' exception b/c there is no :qux key in the spec
210211 ```
211212
212- <br ><sub >[ source] ( https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L267-L513 ) </sub >
213- ## ` rows `
214- <sub >[ source] ( https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L582-L584 ) </sub >
215- ## ` spec->opts `
216- ``` clojure
213+ <p ><sub ><a href =" https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L267-L513 " >Source</a ></sub ></p >
217214
215+ ## <a name =" babashka.cli/spec->opts " >` spec->opts ` </a >
216+ ``` clojure
218217(spec->opts spec)
219218(spec->opts spec {:keys [exec-args]})
220219```
221-
220+ Function.
222221
223222Converts spec into opts format. Pass existing opts as optional second argument.
224- <br ><sub >[ source] ( https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L184-L205 ) </sub >
225- # babashka.cli.exec
223+ <p ><sub ><a href =" https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L184-L205 " >Source</a ></sub ></p >
224+
225+ -----
226+ # <a name =" babashka.cli.exec " >babashka.cli.exec</a >
226227
227228
228229
229230
230231
231- ## ` -main `
232- ``` clojure
233232
233+ ## <a name =" babashka.cli.exec/-main " >` -main ` </a >
234+ ``` clojure
234235(-main & args)
235236```
236-
237+ Function.
237238
238239Main entrypoint for command line usage.
239240 Expects a namespace and var name followed by zero or more key value
@@ -246,11 +247,11 @@ Main entrypoint for command line usage.
246247 clojure -M:exec clojure.core prn :a 1 :b 2
247248 ; ;=> {:a "1" :b "2"}
248249 ```
249- <br ><sub >[ source] ( https://github.com/babashka/cli/blob/main/src/babashka/cli/exec.clj#L97-L110 ) </sub >
250- ## ` main `
251- ``` clojure
250+ <p ><sub ><a href =" https://github.com/babashka/cli/blob/main/src/babashka/cli/exec.clj#L97-L110 " >Source</a ></sub ></p >
252251
252+ ## <a name =" babashka.cli.exec/main " >` main ` </a >
253+ ``` clojure
253254(main & args)
254255```
255-
256- <sub >[ source ] ( https://github.com/babashka/cli/blob/main/src/babashka/cli/exec.clj#L92-L95 ) </ sub >
256+ Function.
257+ <p >< sub >< a href = " https://github.com/babashka/cli/blob/main/src/babashka/cli/exec.clj#L92-L95 " >Source</ a ></ sub ></ p >
0 commit comments