Sha256: 60ea88abbae213d796a91621c78ccb16fdcf5a5089445d71bc234a291d868513

Contents?: true

Size: 1.72 KB

Versions: 3

Compression:

Stored size: 1.72 KB

Contents

#!/usr/bin/env ruby

$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)

require 'optparse'
require 'redis_scanner'

options = {}
OptionParser.new do |opts|
  opts.banner = "Usage: redis_scanner [options]"

  opts.on("-f FILE", "--file FILE", "Output to file") do |v|
    options[:file] = v
  end

  opts.on("-m MATCH", "--match MATCH", "Only scan the pattern") do |v|
    options[:match] = v
  end

  opts.on("-l LIMIT", "--limit LIMIT", "Only show top <limit> keys") do |v|
    options[:limit] = v.to_i
  end

  options[:detail] = false
  opts.on("-d", "--detail", "Show detail info(type & size)") do |v|
    options[:detail] = v
  end

  options[:format] = 'table'
  opts.on("-t FORMAT", "--format FORMAT", "Format(simple or talbe. default is table)") do |v|
    options[:format] = v
  end

  # redis client options
  # -h <hostname>      Server hostname (default: 127.0.0.1).
  # -p <port>          Server port (default: 6379).
  # -s <socket>        Server socket (overrides hostname and port).
  # -a <password>      Password to use when connecting to the server.
  # -n <db>            Database number.
  opts.on("-h HOST", "--host HOST", "Server hostname (default: 127.0.0.1)") do |v|
    options[:host] = v
  end

  opts.on("-p PORT", "--port PORT", "Server port (default: 6379)") do |v|
    options[:port] = v
  end

  opts.on("-s SOCKET", "--socket SOCKET", "Server socket (overrides hostname and port)") do |v|
    options[:socket] = v
  end

  opts.on("-a PASSWORD", "--password PASSWORD", "Password to use when connecting to the server.") do |v|
    options[:password] = v
  end

  opts.on("-n DB", "--db DB", "Database number") do |v|
    options[:db] = v
  end

end.parse!

# puts "options is #{options.inspect}"

RedisScanner.scan options

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
redis_scanner-0.1.6 bin/redis_scanner
redis_scanner-0.1.5 bin/redis_scanner
redis_scanner-0.1.4 bin/redis_scanner