class Derrick::CLI
Public Class Methods
new(args)
click to toggle source
# File lib/derrick/cli.rb, line 98 def initialize(args) @context = Context.new @command, *@arguments = parser.parse(args) end
run(args)
click to toggle source
# File lib/derrick/cli.rb, line 94 def self.run(args) new(args).run! end
Public Instance Methods
command_inspect(database_url=nil)
click to toggle source
# File lib/derrick/cli.rb, line 108 def command_inspect(database_url=nil) inspector = Derrick::Inspector.new(Redis.new(url: database_url), @context) progress_display = ProgressDisplay.new(inspector.progress, STDERR) progress_display.start aggregate = inspector.report progress_display.stop AggregateFormatter.new(aggregate).each do |line| puts line end end
run!()
click to toggle source
# File lib/derrick/cli.rb, line 103 def run! abort! unless @command public_send("command_#{@command}", *@arguments) end
Protected Instance Methods
abort!(message=parser.help)
click to toggle source
# File lib/derrick/cli.rb, line 124 def abort!(message=parser.help) puts message exit 1 end
parser()
click to toggle source
# File lib/derrick/cli.rb, line 129 def parser OptionParser.new do |opts| opts.banner = "Inpect Redis databases to compute statistics on keys" opts.separator "" opts.separator "Usage: derrick inspect [options] DATABASE_URL" opts.separator "" opts.separator "Main options:" opts.on('-c', '--concurrency CONCURRENCY') do |concurrency| @context.concurrency = Integer(concurrency) end opts.on('-b', '--batch-size BATCH_SIZE') do |batch_size| @context.batch_size = Integer(batch_size) end opts.on('-C', '--max-patterns MAX_PATTERNS') do |max_patterns| @context.max_patterns = Integer(max_patterns) end end end