lib/commando/interpreter.rb in tcollier-commando-0.2.1 vs lib/commando/interpreter.rb in tcollier-commando-1.0.0
- old
+ new
@@ -1,18 +1,19 @@
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
+ def initialize(output: $stdout)
@output = output
end
# Performs the action (if valid) for the given input command line
- def interpret
+ #
+ # @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
@@ -20,10 +21,10 @@
end
end
private
- attr_reader :command, :args, :output
+ attr_reader :output
end
private_constant :Interpreter
end