Class: Shell::Options

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details



204
205
206
207
# File 'lib/chef/shell.rb', line 204

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


298
299
300
301
302
303
304
305
306
# File 'lib/chef/shell.rb', line 298

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

.setup!Object



308
309
310
# File 'lib/chef/shell.rb', line 308

def self.setup!
  new.parse_opts
end

Instance Method Details

#parse_optsObject



312
313
314
315
316
317
318
319
320
321
322
323
# File 'lib/chef/shell.rb', line 312

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_shell_mode(environment)
  config_msg = config[:config_file] || "none (standalone 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