# File lib/mcollective/applications.rb, line 84
    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")

      # avoid option parsers own internal version handling that sux
      parser.on("-v", "--verbose")

      if original_extra_opts
        begin
          # optparse will parse the whole ENV in one go and refuse
          # to play along with the retry trick I do below so in
          # order to handle unknown options properly I parse out
          # only -c and --config deleting everything else and
          # then restore the environment variable later when I
          # am done with it
          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