Class: FlyingSphinx::CLI

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

Constant Summary collapse

COMMANDS =
{
  'configure' => [:configure],
  'index'     => [:index],
  'setup'     => [:configure, :index],
  'start'     => [:start],
  'stop'      => [:stop],
  'restart'   => [:stop, :start],
  'rebuild'   => [:stop, :configure, :index, :start]
}

Instance Method Summary collapse

Constructor Details

#initialize(command, arguments = []) ⇒ CLI

Returns a new instance of CLI.



12
13
14
# File 'lib/flying_sphinx/cli.rb', line 12

def initialize(command, arguments = [])
  @command, @arguments = command, arguments
end

Instance Method Details

#runObject



16
17
18
19
20
21
# File 'lib/flying_sphinx/cli.rb', line 16

def run
  methods = COMMANDS[@command]
  raise "Unknown command #{@command}" if methods.nil?

  methods.all? { |method| send method }
end