class ChefCLI::Command::DeletePolicyGroup
def apply_params!(params)
def apply_params!(params) remaining_args = parse_options(params) if remaining_args.size == 1 @policy_group = remaining_args.first true elsif remaining_args.empty? ui.err("You must specify the POLICY_GROUP to delete.") ui.err("") ui.err(opt_parser) false else ui.err("Too many arguments") ui.err("") ui.err(opt_parser) false end 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 @policy_group = nil @rm_policy_group_service = nil @ui = UI.new end
def rm_policy_group_service
def rm_policy_group_service @rm_policy_group_service ||= PolicyfileServices::RmPolicyGroup.new(config: chef_config, ui: ui, policy_group: policy_group) end
def run(params)
def run(params) return 1 unless apply_params!(params) rm_policy_group_service.run ui.msg("This operation can be reversed by running `#{ChefCLI::Dist::EXEC} undelete --last`.") 0 rescue PolicyfileServiceError => e handle_error(e) 1 end