module ChefCLI::RecipeDSLExt

Methods here are mixed in to the Chef recipe DSL to provide extra functionality for generator cookbooks.

Public Instance Methods

silence_chef_formatter() click to toggle source

Replaces the current formatter (by default this is the `doc` formatter) with the null formatter, thus suppressing normal Chef output.

# File lib/chef-cli/command/generator_commands/chef_exts/recipe_dsl_ext.rb, line 28
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