Class ExecuteScript

java.lang.Object
commandManagers.Command
commandManagers.commands.ExecuteScript
All Implemented Interfaces:
CommandInterface

public class ExecuteScript extends Command
ExecuteScript is a class that represents the execute_script command. It reads and executes a script from a file that contains a sequence of commands and arguments. It also prevents recursion by keeping track of file paths that have already been executed.
  • Constructor Details

    • ExecuteScript

      public ExecuteScript()
      Constructs a new ExecuteScript object. Initializes commandMap with the command map from CommandManager, and creates an empty ArrayList of filePaths.
  • Method Details

    • getName

      public String getName()
      Description copied from class: Command
      Base method for show command name
      Specified by:
      getName in interface CommandInterface
      Specified by:
      getName in class Command
      Returns:
      command name
    • getDescr

      public String getDescr()
      Description copied from class: Command
      Base method for show command description.
      Specified by:
      getDescr in interface CommandInterface
      Specified by:
      getDescr in class Command
      Returns:
      command description
    • execute

      public void execute() throws IllegalArgumentException
      Executes the command by reading and parsing the script file. Each command in the file is executed using its corresponding command object from the command map. The method also checks for recursion by ensuring that a file path is not executed twice.
      Specified by:
      execute in interface CommandInterface
      Specified by:
      execute in class Command
      Throws:
      IllegalArgumentException
    • checkArgument

      public boolean checkArgument(Object inputArgument)
      Description copied from class: Command
      Checks if the given inputArgument is valid for this command.
      Specified by:
      checkArgument in interface CommandInterface
      Specified by:
      checkArgument in class Command
      Parameters:
      inputArgument - the argument to check.
      Returns:
      true if the argument is valid, false otherwise.