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.
capture-output
macro
(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"}
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"
print-to-output
(print-to-output ctx printer msg)
Appends the steps output with the given message (see new-printer
for an example)
printed-output
(printed-output printer)
Get the output accumulated in previous print-to-output
calls (see new-printer
for an example)