Method: Qcmd::CLI#start

Defined in:
lib/qcmd/cli.rb

#startObject



292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
# File 'lib/qcmd/cli.rb', line 292

def start
  loop do
    # blocks the whole Ruby VM
    prefix, char = get_prompt

    Qcmd.print prefix
    cli_input = Readline.readline(char, true)

    if cli_input.nil? || cli_input.size == 0
      Qcmd.debug "[CLI start] got: #{ cli_input.inspect }"
      next
    end

    # save all commands to log
    Qcmd::History.push(cli_input)

    begin
      split_and_handle(cli_input)
    rescue => ex
      print "Command parser couldn't handle the last command: #{ ex.message }"
      print ex.backtrace
    end
  end
end