Sha256: 982c456732bd24ffbb66ae53d6a05676dbbe6044d03c8b17f1f3df9457db1ade
Contents?: true
Size: 786 Bytes
Versions: 5
Compression:
Stored size: 786 Bytes
Contents
module Commando # Interpret a single command from the user. class Interpreter # @param input [String] the entire command line string. # @param output [IO] the stream any actions should write messages to. def initialize(input:, output: $stdout) @args = input.split(' ') @command = @args.shift @output = output end # Performs the action (if valid) for the given input command line def interpret 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 :command, :args, :output end private_constant :Interpreter end
Version data entries
5 entries across 5 versions & 1 rubygems