puppetlabs/bolt

Enable streaming output for a block of code

Ziaunys opened this issue · 0 comments

Use Case

I would like to enable streaming output for specific plans without the user needing to know that passing --stream is needed for the best experience. For instance, I want a plan that can tail logs across multiple targets. The plan is completely useless unless they pass in --stream but the caller needs to know this.

Describe the Solution You Would Like

It would be nice if there was a function similar to without_default_logging that accepts a block and enables streaming output for anything that emits log output within.

with_streaming_output () || {
    run_command('tail -f /var/log/messages', $target)
}

Describe Alternatives You've Considered

I've considered just asking users to pass in the flag for the best experience. Printing the message at the top or something, but I don't want to do that every time. It could also just be a documented step.