Class: ChefCLI::Command::CleanPolicyRevisions
- Includes:
 - ChefCLI::Configurable
 
- Defined in:
 - lib/chef-cli/command/clean_policy_revisions.rb
 
Instance Attribute Summary collapse
- 
  
    
      #policy_group  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute policy_group.
 - 
  
    
      #policy_name  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute policy_name.
 - 
  
    
      #ui  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute ui.
 
Instance Method Summary collapse
- #apply_params!(params) ⇒ Object
 - #clean_policies_service ⇒ Object
 - #debug? ⇒ Boolean
 - #handle_error(error) ⇒ Object
 - 
  
    
      #initialize(*args)  ⇒ CleanPolicyRevisions 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of CleanPolicyRevisions.
 - #run(params) ⇒ Object
 
Methods included from ChefCLI::Configurable
#chef_config, #chefcli_config, #config_loader, #generator_config, #knife_config, #reset_config!
Methods inherited from Base
#check_license_acceptance, #needs_help?, #needs_version?, #run_with_default_options
Methods included from Helpers
#err, #git_bin_dir, #git_windows_bin_dir, #msg, #omnibus_bin_dir, #omnibus_embedded_bin_dir, #omnibus_env, #omnibus_expand_path, #omnibus_install?, #omnibus_root, #package_home, #stderr, #stdout, #system_command, #usr_bin_path, #usr_bin_prefix
Constructor Details
#initialize(*args) ⇒ CleanPolicyRevisions
Returns a new instance of CleanPolicyRevisions.
      53 54 55 56  | 
    
      # File 'lib/chef-cli/command/clean_policy_revisions.rb', line 53 def initialize(*args) super @ui = UI.new end  | 
  
Instance Attribute Details
#policy_group ⇒ Object (readonly)
Returns the value of attribute policy_group.
      51 52 53  | 
    
      # File 'lib/chef-cli/command/clean_policy_revisions.rb', line 51 def policy_group @policy_group end  | 
  
#policy_name ⇒ Object (readonly)
Returns the value of attribute policy_name.
      49 50 51  | 
    
      # File 'lib/chef-cli/command/clean_policy_revisions.rb', line 49 def policy_name @policy_name end  | 
  
#ui ⇒ Object
Returns the value of attribute ui.
      47 48 49  | 
    
      # File 'lib/chef-cli/command/clean_policy_revisions.rb', line 47 def ui @ui end  | 
  
Instance Method Details
#apply_params!(params) ⇒ Object
      87 88 89 90 91 92 93 94 95 96 97 98  | 
    
      # File 'lib/chef-cli/command/clean_policy_revisions.rb', line 87 def apply_params!(params) remaining_args = (params) if !remaining_args.empty? ui.err("Too many arguments") ui.err("") ui.err(opt_parser) false else true end end  | 
  
#clean_policies_service ⇒ Object
      68 69 70 71  | 
    
      # File 'lib/chef-cli/command/clean_policy_revisions.rb', line 68 def clean_policies_service @policy_list_service ||= PolicyfileServices::CleanPolicies.new(config: chef_config, ui:) end  | 
  
#debug? ⇒ Boolean
      73 74 75  | 
    
      # File 'lib/chef-cli/command/clean_policy_revisions.rb', line 73 def debug? !!config[:debug] end  | 
  
#handle_error(error) ⇒ Object
      77 78 79 80 81 82 83 84 85  | 
    
      # File 'lib/chef-cli/command/clean_policy_revisions.rb', line 77 def handle_error(error) ui.err("Error: #{error.}") 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  | 
  
#run(params) ⇒ Object
      58 59 60 61 62 63 64 65 66  | 
    
      # File 'lib/chef-cli/command/clean_policy_revisions.rb', line 58 def run(params) return 1 unless apply_params!(params) clean_policies_service.run 0 rescue PolicyfileServiceError => e handle_error(e) 1 end  |