Method: Readis::Inspect#run

Defined in:
lib/readis/inspect.rb

#runObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/readis/inspect.rb', line 28

def run
  loop do
    print "readis #{self.options[:host]}:#{self.options[:port]}> "
    input_string = gets.chomp
    # TODO: tab completion.  Example implementation in automatthew/flipper
    # https://github.com/automatthew/flipper/blob/master/lib/flipper.rb
    # Inititally, we should only try to complete using the list of command
    # names, but we may later consider adding keys, fields, member names, etc.
    # discovered through commands issued.
    begin
      out = execute_command(input_string)
      case out
      when nil
        # do nothing
      else
        # TODO: consider the formatting.  Do we want to mimic
        # the redis-cli output?
        puts out.inspect
      end
    rescue => error
      puts "Error: #{error.message}"
    end
  end
end