Class: Crabfarm::Modes::Console

Inherits:
Object
  • Object
show all
Defined in:
lib/crabfarm/modes/console.rb

Defined Under Namespace

Classes: ConsoleDsl

Class Method Summary collapse

Class Method Details

.process_input(_context) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/crabfarm/modes/console.rb', line 51

def self.process_input(_context)
  dsl = ConsoleDsl.new _context

  loop do
    begin
      dsl.instance_eval Readline.readline("> ", true)
    rescue SyntaxError => se
      puts "Syntax error: #{se.message}".color(:red)
    rescue SystemExit, Interrupt
      break
    rescue => e
      puts "Unknown command".color(:red)
    end
  end

  puts "Exiting".color(:green)
end