module ChefCLI::RecipeDSLExt

def silence_chef_formatter

with the null formatter, thus suppressing normal Chef output.
Replaces the current formatter (by default this is the `doc` formatter)
def silence_chef_formatter
  old = run_context.events.subscribers.first
  out, err = old.output.out, old.output.err
  run_context.events.subscribers.clear
  null_formatter = Chef::Formatters.new(:null, out, err)
  run_context.events.register(null_formatter)
end