Class: Shell::Options
- Inherits:
-
Object
- Object
- Shell::Options
- Includes:
- ChefConfig::Mixin::DotD, Mixlib::CLI
- Defined in:
- lib/chef/shell.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.footer(text = nil) ⇒ Object
217 218 219 220 |
# File 'lib/chef/shell.rb', line 217 def self.(text = nil) @footer = text if text @footer end |
.print_help ⇒ Object
326 327 328 329 330 331 332 333 334 |
# File 'lib/chef/shell.rb', line 326 def self.print_help instance = new instance.([]) puts instance.opt_parser puts puts puts exit 1 end |
.setup! ⇒ Object
336 337 338 |
# File 'lib/chef/shell.rb', line 336 def self.setup! new.parse_opts end |
Instance Method Details
#parse_opts ⇒ Object
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 |
# File 'lib/chef/shell.rb', line 340 def parse_opts remainder = 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 # This code should not exist. # We should be using Application::Client and then calling load_config_file # which does all this properly. However this will do for now. config[:config_file] = config_file_for_shell_mode(environment) config_msg = config[:config_file] || "none (standalone session)" puts "loading configuration: #{config_msg}" # load the config (if we have one) unless config[:config_file].nil? if File.exist?(config[:config_file]) && File.readable?(config[:config_file]) Chef::Config.from_file(config[:config_file]) end # even if we couldn't load that, we need to tell Chef::Config what # the file was so it sets conf dir and d_dir and such properly Chef::Config[:config_file] = config[:config_file] # now attempt to load any relevant dot-dirs load_dot_d(Chef::Config[:client_d_dir]) if Chef::Config[:client_d_dir] end # finally merge command-line options in Chef::Config.merge!(config) end |