Module: Tr3llo::Controller

Extended by:
Controller
Included in:
Controller
Defined in:
lib/3llo/controller.rb

Instance Method Summary collapse

Instance Method Details

#start(init_command) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/3llo/controller.rb', line 7

def start(init_command)
  Readline.completion_append_character = " "
  Readline.completion_proc = lambda { |buffer|
    Command.generate_suggestions(buffer, Readline.line_buffer)
  }

  interface = Application.fetch_interface!()

  if init_command && init_command != ""
    init_commands = init_command.split(";")
    init_commands.each do |cmd|
      interface.puts("Executing " + Utils.format_highlight(cmd) + " command")
      execute_command!(cmd)
    end
  end

  loop do
    status_line = determine_status_line()
    command_buffer = Readline.readline(status_line, true)
    Command::Exit.execute() if command_buffer.nil?

    execute_command!(command_buffer)
  end
rescue Interrupt
  Command::Exit.execute()
end