Class JBangOperation


public class JBangOperation extends AbstractOperation<JBangOperation>
Run JBang with the specified arguments.
Since:
1.0
Author:
Erik C. Thauvin
  • Constructor Details

    • JBangOperation

      public JBangOperation()
  • Method Details

    • isLinux

      public static boolean isLinux()
      Determines if the operating system is Linux.
      Returns:
      true if the operating system is Linux, false otherwise.
    • isMacOS

      public static boolean isMacOS()
      s Determines if the current operating system is macOS.
      Returns:
      true if the OS is macOS, false otherwise.
    • isWindows

      public static boolean isWindows()
      Determines if the current operating system is Windows.
      Returns:
      true if the operating system is Windows, false otherwise.
    • args

      public JBangOperation args(Collection<String> args)
      Sets the arguments to be used in the script.
      Parameters:
      args - the arguments to use in the script
      Returns:
      this operation instance
    • args

      public JBangOperation args(String... args)
      Sets the arguments to be used in the script.
      Parameters:
      args - the arguments to use in the script
      Returns:
      this operation instance
    • args

      public Collection<String> args()
      Retrieves the collection of arguments to be passed to the script.
      Returns:
      a collection of arguments
    • execute

      public void execute() throws Exception
      Performs the operation
      Specified by:
      execute in class AbstractOperation<JBangOperation>
      Throws:
      Exception - if an error occurs
    • exitOnFailure

      public JBangOperation exitOnFailure(boolean exitOnFailure)
      Configures whether the operation should exit upon a JBang execution failure.

      Default value is true

      Parameters:
      exitOnFailure - true if the operation should exit on failure, false otherwise
      Returns:
      this operation instance
    • fromProject

      public JBangOperation fromProject(BaseProject project)
      Configures a compile operation from a BaseProject.

      Sets the following from the project:

      • workDir to the project's directory.
      • jBangHome to the JBANG_HOME environment variable if set
      Parameters:
      project - the project to configure the compile operation from
      Returns:
      this operation instance
    • isExitOnFailure

      public boolean isExitOnFailure()
      Checks whether the operation is configured to exit upon a JBang execution failure.

      Default value is true

      Returns:
      true if the operation is set to exit on failure, false otherwise.
    • jBangArgs

      public JBangOperation jBangArgs(Collection<String> jBangArgs)
      Sets the arguments to be used when running the script
      Parameters:
      jBangArgs - the arguments to use when running the script
      Returns:
      this operation instance
    • jBangArgs

      public JBangOperation jBangArgs(String... jBangArgs)
      Sets one or more arguments to be used when running the script.
      Parameters:
      jBangArgs - the arguments to use when running the script
      Returns:
      this operation instance
    • jBangArgs

      public Collection<String> jBangArgs()
      Retrieves the collection of arguments to be used when running the script.
      Returns:
      a collection of script arguments
    • jBangHome

      public JBangOperation jBangHome(String jBangHome)
      Sets the JBang home directory.
      Parameters:
      jBangHome - the JBang home directory
      Returns:
      this operation instance
    • jBangHome

      public JBangOperation jBangHome(File jBangHome)
      Sets the JBang home directory.
      Parameters:
      jBangHome - the JBang home directory
      Returns:
      this operation instance
    • jBangHome

      public JBangOperation jBangHome(Path jBangHome)
      Sets the JBang home directory.
      Parameters:
      jBangHome - the JBang home directory
      Returns:
      this operation instance
    • jBangHome

      public File jBangHome()
      Retrieves the JBang home directory.
      Returns:
      the JBang home directory
    • reset

      public void reset()
      Resets the state of the operation to its default values.

      Clears all jBang arguments used for execution, resets the exit on failure flag to true, removes the assigned script and arguments.

    • script

      public JBangOperation script(String script)
      Sets the script to be executed.
      Parameters:
      script - the script to execute
      Returns:
      this operation instance
    • script

      public String script()
      Retrieves the script that has been set for execution.
      Returns:
      the script to be executed or null
    • workDir

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

      public JBangOperation workDir(File dir)
      Provides the working directory if it differs from the project's directory.
      Parameters:
      dir - the directory
      Returns:
      this operation instance
    • workDir

      public JBangOperation workDir(Path dir)
      Provides the working directory if it differs from the project's directory.
      Parameters:
      dir - the directory
      Returns:
      this operation instance
    • workDir

      public JBangOperation workDir(String dir)
      Provides the working directory if it differs from the project's directory.
      Parameters:
      dir - the directory path
      Returns:
      this operation instance