Functions and macros that simplify dealing with a steps user readable output (:out
). Two approaches are provided:
The printer approach that gives full control over what will be provided as output and the capture-output
-approach that just redirects all stdout.
Functions and macros that simplify dealing with a steps user readable output (`:out`). Two approaches are provided: The _printer_ approach that gives full control over what will be provided as output and the `capture-output`-approach that just redirects all stdout.
(capture-output ctx & body)
Redirect build steps stdout to its :out
channel by rebinding clojure-stdout.
If the result of the given body is a map (like a step-result), it automatically prepends the collected stdout to :out
.
Example:
> (capture-output (some-ctx)
(println "Hello")
(println "World")
{:status :success
:out "From Step"})
{:status :success, :out "Hello\nWorld\n\nFrom Step"}
Redirect build steps stdout to its `:out` channel by rebinding clojure-stdout. If the result of the given body is a map (like a step-result), it automatically prepends the collected stdout to `:out`. Example: ```clojure > (capture-output (some-ctx) (println "Hello") (println "World") {:status :success :out "From Step"}) {:status :success, :out "Hello\nWorld\n\nFrom Step"} ```
(new-printer)
Returns a datastructure to collect output (to be used with print-to-output
and printed-output
).
Example:
> (let [printer (new-printer)]
(print-to-output ctx printer "Hello")
(print-to-output ctx printer "World")
(printed-output printer))
"Hello\nWorld\n"
Returns a datastructure to collect output (to be used with `print-to-output` and `printed-output`). Example: ```clojure > (let [printer (new-printer)] (print-to-output ctx printer "Hello") (print-to-output ctx printer "World") (printed-output printer)) "Hello\nWorld\n" ```
(print-to-output ctx printer msg)
Appends the steps output with the given message (see new-printer
for an example)
Appends the steps output with the given message (see `new-printer` for an example)
(printed-output printer)
Get the output accumulated in previous print-to-output
calls (see new-printer
for an example)
Get the output accumulated in previous `print-to-output` calls (see `new-printer` for an example)
(set-output ctx msg)
Reset the steps output to the given value.
Reset the steps output to the given value.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close