class ChefCLI::Command::DeletePolicyGroup
Attributes
policy_group[R]
ui[RW]
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
ChefCLI::Command::Base::new
# File lib/chef-cli/command/delete_policy_group.rb, line 62 def initialize(*args) super @policy_group = nil @rm_policy_group_service = nil @ui = UI.new end
Public Instance Methods
apply_params!(params)
click to toggle source
# File lib/chef-cli/command/delete_policy_group.rb, line 101 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
debug?()
click to toggle source
# File lib/chef-cli/command/delete_policy_group.rb, line 87 def debug? !!config[:debug] end
handle_error(error)
click to toggle source
# File lib/chef-cli/command/delete_policy_group.rb, line 91 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
rm_policy_group_service()
click to toggle source
# File lib/chef-cli/command/delete_policy_group.rb, line 80 def rm_policy_group_service @rm_policy_group_service ||= PolicyfileServices::RmPolicyGroup.new(config: chef_config, ui: ui, policy_group: policy_group) end
run(params)
click to toggle source
# File lib/chef-cli/command/delete_policy_group.rb, line 69 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