def self.load_config
return if Config.instance.configured
original_argv = ARGV.clone
original_extra_opts = ENV["MCOLLECTIVE_EXTRA_OPTS"].clone rescue nil
configfile = nil
parser = OptionParser.new
parser.on("--config CONFIG", "-c", "Config file") do |f|
configfile = f
end
parser.program_name = $0
parser.on("--help")
parser.on("-v", "--verbose")
if original_extra_opts
begin
ENV["MCOLLECTIVE_EXTRA_OPTS"] = filter_extra_options(ENV["MCOLLECTIVE_EXTRA_OPTS"].clone)
parser.environment("MCOLLECTIVE_EXTRA_OPTS")
rescue Exception => e
Log.error("Failed to parse MCOLLECTIVE_EXTRA_OPTS: #{e}")
end
ENV["MCOLLECTIVE_EXTRA_OPTS"] = original_extra_opts.clone
end
begin
parser.parse!
rescue OptionParser::InvalidOption => e
retry
end
ARGV.clear
original_argv.each {|a| ARGV << a}
configfile = Util.config_file_for_user unless configfile
Config.instance.loadconfig(configfile)
end