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
226 227 228 229 |
# File 'lib/chef/shell.rb', line 226 def self.(text = nil) @footer = text if text @footer end |
.print_help ⇒ Object
335 336 337 338 339 340 341 342 343 |
# File 'lib/chef/shell.rb', line 335 def self.print_help instance = new instance.([]) puts instance.opt_parser puts puts puts exit 1 end |
.setup! ⇒ Object
345 346 347 |
# File 'lib/chef/shell.rb', line 345 def self.setup! new.parse_opts end |
Instance Method Details
#parse_opts ⇒ Object
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 |
# File 'lib/chef/shell.rb', line 349 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 |