# frozen_string_literal: true require "thor" module ToyRobotCli class CLI < Thor VALID_DIRECTIONS = %w[NORTH EAST SOUTH WEST].freeze def initialize(*args) super @robot = Robot.new end desc "place X Y FACING", "Place the robot on the table" def place(x, y, facing) @robot.place(x.to_i, y.to_i, facing.upcase) end desc "move", "Move the robot one unit forward in the current direction" def move @robot.move end desc "left", "Rotate the robot 90 degrees to the left" def left @robot.left end desc "right", "Rotate the robot 90 degrees to the right" def right @robot.right end desc "report", "Report the current position and direction of the robot" def report puts @robot.report end desc "interactive", "Interactive mode to input commands" def interactive loop do print "> " input = $stdin.gets.chomp.downcase command, *args = input.split(" ") case command when "place" place(*args) when "move" move when "left" left when "right" right when "report" report when "exit" break else puts "Invalid command. Please try again." end end end default_task :interactive end end