bin/mass
#!/usr/bin/env ruby
# Converts redis protocol to piped redis protocol
#
# Usage:
# echo "SET foo bar" | bin/mass | redis-cli --pipe
def gen_redis_proto(*cmd)
proto = ""
proto << "*"+cmd.length.to_s+"\r\n"
cmd.each{|arg|
proto << "$"+arg.to_s.bytesize.to_s+"\r\n"
proto << arg.to_s+"\r\n"
}
proto
end
STDIN.each_line do |line|
STDOUT.write(gen_redis_proto(*line.strip.split(' ')))
end