CLI-matic 0.3.0 works with Planck! Planck is a stand-alone ClojureScript REPL for macOS and Linux based on JavaScriptCore that includes a small emulation library for common shell functions (eg reading files, variables, forking processes) so it is very easy to use for scripting. http://planck-repl.org/
To start toying, you need to have Planck installed; just clone this repo, go to ''examples-cljs-planck'' and run the files in there.
Some commands you may want to try:
./toycalc.cljs
./toycalc.cljs add -?
./toycalc.cljs --base 16 add -a 10 -b 20
AA=10 ./toycalc.cljs --base 16 add -b 20
./toycalc-spec.cljs
./toycalc-spec.cljs add -?
./toycalc-spec.cljs add -a 1 -b 2
./toycalc-spec.cljs add -a 1 -b 1
Note how they are self-contained; just one file for each scripts. Also note how you waste no time on boilerplate functions, and you get help and parameter validation for free.
You will also notice that these commmands use the source version of CLI-matic, so they are valid examples but do not use that approach in your own scripts :-) - see below.
Scripting with Planck is very similar to Clojure; there are a few things that you should remember:
#!/usr/bin/env bash
"exec" "plk" "-Sdeps" "{:deps {cli-matic {:mvn/version \"0.3.7\"}}}" "-Ksf" "$0" "$@"
(set! *main-cli-fn* -main)
so Planck knows where to start the script.On first run, with compilation, you will get a number of warnings; some are caused by CLI-matic and we plan to fix them, and some are caused by dependencies. CLI-matic 0.3.7 does not show additional warnings.
WARNING: toycalc is a single segment namespace at line 4
WARNING: Use of undeclared Var clojure.tools.cli/Exception at line 126 clojure/tools/cli.cljc
WARNING: Use of undeclared Var clojure.tools.cli/Exception at line 126 clojure/tools/cli.cljc
WARNING: Use of undeclared Var clojure.tools.cli/*err* at line 228 clojure/tools/cli.cljc
In spite of this, the library is currently usable!
When debugging, it is sometimes useful to:
"{:deps {cli-matic {:local/root \"../target/cli-matic-0.2.16-SNAPSHOT.jar\"}}}"
.planck-cache/
folder before each run"-v"
for verbose compilationclojure.spec
parameter validationread-file.cljs
)exit-status.cljs
)read-file.cljs
)read-file.cljs
)Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close