Class: Shef::Options

Inherits:
Object
  • Object
show all
Includes:
Mixlib::CLI
Defined in:
lib/chef/shef.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details



198
199
200
201
# File 'lib/chef/shef.rb', line 198

def self.footer(text=nil)
  @footer = text if text
  @footer
end


272
273
274
275
276
277
278
279
280
# File 'lib/chef/shef.rb', line 272

def self.print_help
  instance = new
  instance.parse_options([])
  puts instance.opt_parser
  puts
  puts footer
  puts
  exit 1
end

.setup!Object



282
283
284
# File 'lib/chef/shef.rb', line 282

def self.setup!
  self.new.parse_opts
end

Instance Method Details

#parse_optsObject



286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/chef/shef.rb', line 286

def parse_opts
  remainder = parse_options
  environment = remainder.first
  # We have to nuke ARGV to make sure irb's option parser never sees it.
  # otherwise, IRB complains about command line switches it doesn't recognize.
  ARGV.clear
  config[:config_file] = config_file_for_shef_mode(environment)
  config_msg = config[:config_file] || "none (standalone shef session)"
  puts "loading configuration: #{config_msg}"
  Chef::Config.from_file(config[:config_file]) if !config[:config_file].nil? && File.exists?(config[:config_file]) && File.readable?(config[:config_file])
  Chef::Config.merge!(config)
end