import cv2 as cv
from core.Logger import Logger

class CLIAgent:
  def __init__(self, mainAgent) -> None:
    self.isRunning = False
    self.logger = Logger("CliAgent")
    if (not mainAgent):
        raise Exception("Main agent not found...")
    self.mainAgent = mainAgent

  def printMenu(self):
    print("Enter a command:")
    print("\tH\tHelp.")
    print("\tF\tStart the fishing agent.")
    print("\tQ\tQuit.")
    print("$>> ", end='')

  def run(self):
    self.isRunning = True

    self.printMenu()
    while self.isRunning is True:
      userInput = input()
      userInput = str.lower(userInput).strip()

      if (userInput == "f"):
        self.logger.log("Starting Fishing bot...")
        self.mainAgent.startFishBot()
      elif (userInput == "h"):
        self.printMenu()
      elif (userInput == "q"):
        cv.destroyAllWindows()
        self.logger.log("Exiting application...")
        self.isRunning = False
      else:
        self.logger.log("Unknown Command.")
        self.printMenu()

