Sha256: a6c1e5c8a22ca3e29606ea85748c0297da12086421e9fc5a4fe37c92314ba636
Contents?: true
Size: 1.27 KB
Versions: 2
Compression:
Stored size: 1.27 KB
Contents
require_relative 'commando/config' require_relative 'commando/interpreter' require_relative 'commando/io_handler' require_relative 'commando/quit_exception' require_relative 'commando/validation_error' 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) 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 = Interpreter.new(input: line, output: output) interpreter.interpret end rescue ValidationError => error output.puts "Error: #{error}" rescue QuitException break end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tcollier-commando-0.2.1 | lib/commando.rb |
tcollier-commando-0.2.0 | lib/commando.rb |