class Shell::Options
Public Class Methods
print_help()
click to toggle source
# 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!()
click to toggle source
# File lib/chef/shell.rb, line 308 def self.setup! new.parse_opts end
Public Instance Methods
parse_opts()
click to toggle source
# 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
Private Instance Methods
config_file_for_shell_mode(environment)
click to toggle source
# File lib/chef/shell.rb, line 327 def config_file_for_shell_mode(environment) dot_chef_dir = Chef::Util::PathHelper.home(".chef") if config[:config_file] config[:config_file] elsif environment Shell.env = environment config_file_to_try = ::File.join(dot_chef_dir, environment, Chef::Dist::SHELL_CONF) unless ::File.exist?(config_file_to_try) puts "could not find #{Chef::Dist::SHELL} config for environment #{environment} at #{config_file_to_try}" exit 1 end config_file_to_try elsif dot_chef_dir && ::File.exist?(File.join(dot_chef_dir, Chef::Dist::SHELL_CONF)) File.join(dot_chef_dir, Chef::Dist::SHELL_CONF) elsif config[:solo_legacy_shell] Chef::Config.platform_specific_path("#{Chef::Dist::CONF_DIR}/solo.rb") elsif config[:client] Chef::Config.platform_specific_path("#{Chef::Dist::CONF_DIR}/client.rb") elsif config[:solo_shell] Chef::WorkstationConfigLoader.new(nil, Chef::Log).config_location else nil end end