Method: ChefApply::CLI#perform_run

Defined in:
lib/chef_apply/cli.rb

#perform_run(enforce_license: false) ⇒ Object



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/chef_apply/cli.rb', line 103

def perform_run(enforce_license: false)
  parse_options(@argv)
  if @argv.empty? || parsed_options[:help]
    show_help
  elsif parsed_options[:version]
    show_version
  else
    check_license_acceptance if enforce_license
    validate_params(cli_arguments)
    target_hosts = resolve_targets(cli_arguments.shift, parsed_options)
    render_cookbook_setup(cli_arguments)
    render_converge(target_hosts)
  end
rescue OptionParser::InvalidOption => e # from parse_options
  # Using nil here is a bit gross but it prevents usage from printing.
  ove = OptionValidationError.new("CHEFVAL010", nil,
    e.message.split(":")[1].strip, # only want the flag
    format_flags.lines[1..-1].join) # remove 'FLAGS:' header
  handle_perform_error(ove)
rescue => e
  handle_perform_error(e)
ensure
  temp_cookbook.delete unless temp_cookbook.nil?
end