Class ExecOperation


public class ExecOperation extends AbstractOperation<ExecOperation>
Executes a command on the command line.
Since:
1.0
Author:
Erik C. Thauvin
  • Constructor Details

    • ExecOperation

      public ExecOperation()
  • Method Details

    • command

      public ExecOperation command(String... arg)
      Configures the command and arguments to be executed.

      For example:

      • command("cmd", "/c", "stop.bat")
      • command("./stop.sh"
      Parameters:
      arg - one or more arguments
      Returns:
      this operation instance
      See Also:
    • command

      public Collection<String> command()
      Returns the command and arguments to be executed.
      Returns:
      the command and arguments
    • command

      public ExecOperation command(Collection<String> args)
      Configures the command and arguments to be executed.
      Parameters:
      args - the list of arguments
      Returns:
      this operation instance
      See Also:
    • execute

      public void execute() throws Exception
      Executes the command.
      Specified by:
      execute in class AbstractOperation<ExecOperation>
      Throws:
      Exception
    • failOnExit

      public ExecOperation failOnExit(boolean failOnExit)
      Configures whether the operation should fail if the command exit value/status is not 0.

      Default is TRUE

      Parameters:
      failOnExit - The fail on exit toggle
      Returns:
      this operation instance.
    • fromProject

      public ExecOperation fromProject(BaseProject project)
      Configures an Exec operation from a BaseProject.
      Parameters:
      project - the project
      Returns:
      this operation instance
    • isFailOnExit

      public boolean isFailOnExit()
      Returns whether the operation should fail if the command exit value/status is not 0.
      Returns:
      true or false
    • timeout

      public ExecOperation timeout(int timeout)
      Configure the command timeout.
      Parameters:
      timeout - The timeout in seconds
      Returns:
      this operation instance
    • timeout

      public int timeout()
      Returns the command timeout.
      Returns:
      the timeout
    • workDir

      public ExecOperation workDir(File dir)
      Configures the working directory.
      Parameters:
      dir - the directory
      Returns:
      this operation instance
    • workDir

      public ExecOperation workDir(Path dir)
      Configures the working directory.
      Parameters:
      dir - the directory
      Returns:
      this operation instance
    • workDir

      public ExecOperation workDir(String dir)
      Configures the working directory.
      Parameters:
      dir - the directory path
      Returns:
      this operation instance
    • workDir

      public File workDir()
      Returns the working directory.
      Returns:
      the directory