Class: Derrick::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/derrick/cli.rb

Defined Under Namespace

Classes: AggregateFormatter, Context, ProgressDisplay

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ CLI

Returns a new instance of CLI.



100
101
102
103
# File 'lib/derrick/cli.rb', line 100

def initialize(args)
  @context = Context.new
  @command, *@arguments = parser.parse(args)
end

Class Method Details

.run(args) ⇒ Object



96
97
98
# File 'lib/derrick/cli.rb', line 96

def self.run(args)
  new(args).run!
end

Instance Method Details

#command_inspect(database_url = nil) ⇒ Object



110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/derrick/cli.rb', line 110

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!Object



105
106
107
108
# File 'lib/derrick/cli.rb', line 105

def run!
  abort! unless @command
  public_send("command_#{@command}", *@arguments)
end