class Commando::Interpreter
Interpret a single command from the user.
Attributes
config[R]
Public Class Methods
new(config:)
click to toggle source
@param config [Config] the application configuration
# File lib/commando/interpreter.rb, line 5 def initialize(config:) @config = config end
Public Instance Methods
interpret(line)
click to toggle source
Performs the action (if valid) for the given input command line
@param line [String] the entire command line string.
# File lib/commando/interpreter.rb, line 12 def interpret(line) args = line.split(' ') command = args.shift action = config.lookup(command) if action.nil? config.output.puts %Q(Unrecognized command: #{command}. Type "help" for a list of valid commands) else action.perform(args: args) end end