initialize

in lib/omnibus/cli/base.rb [42:86]


    def initialize(args, options, config)
      super(args, options, config)

      
      if @options[:log_level]
        Omnibus.logger.level = @options[:log_level]
      end

      
      if %w{help version}.include?(config[:current_command].name)
        log.debug(log_key) { "Skipping Omnibus loading (detected help or version)" }
        return
      end

      if File.exist?(@options[:config])
        log.info(log_key) { "Using config from '#{@options[:config]}'" }
        Omnibus.load_configuration(@options[:config])
      else
        if @options[:config] == Omnibus::DEFAULT_CONFIG
          log.debug(log_key) { "Config file not given - using defaults" }
        else
          raise "The given config file '#{@options[:config]}' does not exist!"
        end
      end

      @options[:override].each do |key, value|
        if %w{true false nil}.include?(value)
          log.debug(log_key) { "Detected #{value.inspect} should be an object" }
          value = { "true" => true, "false" => false, "nil" => nil }[value]
        end

        if value =~ /\A[[:digit:]]+\Z/
          log.debug(log_key) { "Detected #{value.inspect} should be an integer" }
          value = value.to_i
        end

        if Config.respond_to?(key)
          log.debug(log_key) { "Setting Config.#{key} = #{value.inspect}" }
          Config.send(key, value)
        else
          log.debug (log_key) { "Skipping option '#{key}' - not a config option" }
        end
      end
    end