class ChefCLI::Command::CleanPolicyCookbooks

def apply_params!(params)

def apply_params!(params)
  remaining_args = parse_options(params)
  if !remaining_args.empty?
    ui.err("Too many arguments")
    ui.err("")
    ui.err(opt_parser)
    false
  else
    true
  end
end

def clean_policy_cookbooks_service

def clean_policy_cookbooks_service
  @clean_policy_cookbooks_service ||=
    PolicyfileServices::CleanPolicyCookbooks.new(config: chef_config, ui: ui)
end

def debug?

def debug?
  !!config[:debug]
end

def handle_error(error)

def handle_error(error)
  ui.err("Error: #{error.message}")
  if error.respond_to?(:reason)
    ui.err("Reason: #{error.reason}")
    ui.err("")
    ui.err(error.extended_error_info) if debug?
    ui.err(error.cause.backtrace.join("\n")) if debug?
  end
end

def initialize(*args)

def initialize(*args)
  super
  @ui = UI.new
  @clean_policy_cookbooks_service = nil
end

def run(params)

def run(params)
  return 1 unless apply_params!(params)
  clean_policy_cookbooks_service.run
  0
rescue PolicyfileServiceError => e
  handle_error(e)
  1
end