Sha256: 1ec26c20d634c0f72d8f1cc64f7610860a73cf7b829eb9628a55d9cddb52cee3
Contents?: true
Size: 768 Bytes
Versions: 1
Compression:
Stored size: 768 Bytes
Contents
module Commando # Interpret a single command from the user. class Interpreter # @param output [IO] the stream any actions should write messages to. def initialize(output: $stdout) @output = output end # Performs the action (if valid) for the given input command line # # @param line [String] the entire command line string. def interpret(line) args = line.split(' ') command = args.shift action = Commando.config.lookup(command) if action.nil? output.puts %Q(Unrecognized command: #{command}. Type "help" for a list of valid commands) else action.perform(args: args, output: output) end end private attr_reader :output end private_constant :Interpreter end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tcollier-commando-1.0.0 | lib/commando/interpreter.rb |