Created
March 15, 2014 19:36
-
-
Save JakubOboza/9572676 to your computer and use it in GitHub Desktop.
if you need a quick check on riak buckets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "rubygems" | |
require "bundler/setup" | |
require 'riak' | |
require 'optparse' | |
options = {} | |
OptionParser.new do |opts| | |
opts.banner = "Usage: pebble.rb [options]" | |
opts.on("-B","--buckets", "list buckets names") do |bs| | |
options[:buckets] = true | |
end | |
opts.on("-b","--bucket <name>", String, "list keys in bucket <name>") do |bucket_name| | |
options[:bucket] = bucket_name | |
end | |
opts.on("-p","--port <number>", String, "protocol buffer port") do |port| | |
options[:port] = port | |
end | |
end.parse! | |
params = {:protocol => "pbc"} | |
params.merge!(:pb_port => options[:port]) if options[:port] | |
client = Riak::Client.new(params) | |
puts options.inspect | |
if options[:buckets] | |
client.buckets.each do |bucket| | |
puts bucket.name | |
end | |
end | |
if options[:bucket] | |
bucket = client.bucket(options[:bucket]) | |
puts bucket.keys | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment