Sha256: 38406c0feb9b67a3788b60952fd5a1217a85847667f3ae12a607b8d2ab4133b2
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
require_relative 'commando/config' require_relative 'commando/interpreter' require_relative 'commando/io_handler' require_relative 'commando/quit_exception' require_relative 'commando/version' # Entry point for the Command Line Interface (CLI). # # Present the user with a text-based interface, where a prompt is printed, # then commands are read from stardard in, then executed. This process is # repeated indefinitely until the user give either the "quit" command, or # presses <CMD>+D. module Commando # Initialize and configure the global config object def self.configure(&block) yield config end def self.config @config ||= Config.new end # Begin the prompt, get input, process loop. def self.start(output: $stdout) output.puts config.greeting io = IOHandler.new(output: output) interpreter = Interpreter.new(output: output) 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 output.puts "Error: #{error}" rescue QuitException break end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tcollier-commando-1.0.0 | lib/commando.rb |