Liking cljdoc? Tell your friends :D

lambdacd.stepsupport.output

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-outputmacro

(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"}
```
sourceraw docstring

new-printer

(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"
```
sourceraw docstring

(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)
sourceraw docstring

printed-output

(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)
sourceraw docstring

set-output

(set-output ctx msg)

Reset the steps output to the given value.

Reset the steps output to the given value.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close