lib/octofacts_updater/cli.rb
# Run method. Call this to run the octofacts updater with the object that was
# previously construcuted.
Run method. Call this to run the octofacts updater with the object that was
previously construcuted.
Run method . Call this to run the octofacts updater with the object that was previously construcuted .
def run
      unless opts[:action]
        usage
        exit 255
      end
      @config = {}
      if opts[:config]
        @config = YAML.load_file(opts[:config])
        substitute_relative_paths!(@config, File.dirname(opts[:config]))
        load_plugins(@config["plugins"]) if @config.key?("plugins")
      end
      @config[:options] = {}
      opts.each do |k, v|
        if v.is_a?(Hash)
          @config[k.to_s] ||= {}
          v.each do |v_key, v_val|
            @config[k.to_s][v_key.to_s] = v_val
            @config[k.to_s].delete(v_key.to_s) if v_val.nil?
          end
        else
          @config[:options][k] = v
        end
      end
      return handle_action_bulk if opts[:action] == "bulk"
      return handle_action_facts if opts[:action] == "facts"
      return handle_action_bulk if opts[:action] == "reindex"
      usage
      exit 255
    end
def run unless opts [ :action ] usage exit 255 end @config = { } if opts [ :config ] @config = YAML . load_file ( opts [ :config ] ) substitute_relative_paths! ( @config , File . dirname ( opts [ :config ] ) ) load_plugins ( @config [ "plugins" ] ) if @config . key? ( "plugins" ) end @config [ :options ] = { } opts . each do | k , v | if v . is_a? ( Hash ) @config [ k . to_s ] ||= { } v . each do | v_key , v_val | @config [ k . to_s ] [ v_key . to_s ] = v_val @config [ k . to_s ] . delete ( v_key . to_s ) if v_val . nil? end else @config [ :options ] [ k ] = v end end return handle_action_bulk if opts [ :action ] == "bulk" return handle_action_facts if opts [ :action ] == "facts" return handle_action_bulk if opts [ :action ] == "reindex" usage exit 255 end
Run method.
Run method .