Sha256: 4bad47754a3d8d0776070d69b22fbef23aba85202e795a653e752fdb3aa97406

Contents?: true

Size: 997 Bytes

Versions: 5

Compression:

Stored size: 997 Bytes

Contents

#!/usr/bin/env ruby

$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
begin
  require 'redis'
rescue LoadError
  require 'rubygems'
  require 'redis'
end
require 'soulmate'
require 'optparse'

parser = OptionParser.new do |opts|
  opts.banner = "Usage: soulmate [options] COMMAND"

  opts.separator ""
  opts.separator "Options:"

  opts.on("-r", "--redis [HOST:PORT]", "Redis connection string") do |host|
    Soulmate.redis = host
  end

  opts.on("-h", "--help", "Show this message") do
    puts opts
    exit
  end

  opts.separator ""
  opts.separator "Commands:"
  opts.separator "  load TYPE   Loads items of specified type read from stdin in the JSON lines format"
end

def load(type)
  puts "Loading items of type #{type}..."
  items = $stdin.read.split("\n").map { |l| JSON.parse(l) }
  total = Soulmate::Loader.new(type).load(items)
  puts "Loaded a total of #{total} items"
end

parser.parse!

case ARGV[0]
when 'load'
  load ARGV[1]
else
  puts parser.help
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
soulmate-0.0.4 bin/soulmate
soulmate-0.0.3 bin/soulmate
soulmate-0.0.2 bin/soulmate
soulmate-0.0.1 bin/soulmate
soulmate-0.0.0 bin/soulmate