class Commando::Runner

Attributes

config[R]

Public Class Methods

new(config:) click to toggle source
# File lib/commando/runner.rb, line 7
def initialize(config:)
  @config = config
end

Public Instance Methods

start() click to toggle source
# File lib/commando/runner.rb, line 11
def start
  config.output.puts config.greeting

  io = IOHandler.new(config: config)
  interpreter = Interpreter.new(config: config)

  loop do
    begin
      if line = io.readline
        # When the user enters a non-empty string, pass the line to the
        # interpreter and handle the command.
        interpreter.interpret(line)
      end
    rescue ArgumentError => error
      config.output.puts "Error: #{error}"
    rescue QuitException
      break
    end
  end
end