Class PipelineBuilder

java.lang.Object
org.jline.shell.PipelineBuilder

public class PipelineBuilder extends Object
Fluent builder for constructing Pipeline instances programmatically.

Example:

 Pipeline pipeline = Pipeline.of("ls -la")
     .pipe("grep pattern")
     .redirect(Path.of("output.txt"))
     .build();
 
Since:
4.0
See Also:
  • Method Details

    • pipe

      public PipelineBuilder pipe(String command)
      Adds a pipe (|) to the next command.
      Parameters:
      command - the next command to pipe to
      Returns:
      this builder
    • flip

      public PipelineBuilder flip(String command)
      Adds a flip pipe (|;) to the next command. The output of the previous command is appended as an argument to the next.
      Parameters:
      command - the next command
      Returns:
      this builder
    • and

      public PipelineBuilder and(String command)
      Adds a conditional AND (&&) to the next command. The next command executes only if the previous succeeded.
      Parameters:
      command - the next command
      Returns:
      this builder
    • or

      public PipelineBuilder or(String command)
      Adds a conditional OR (||) to the next command. The next command executes only if the previous failed.
      Parameters:
      command - the next command
      Returns:
      this builder
    • sequence

      public PipelineBuilder sequence(String command)
      Adds a sequence separator (;) to the next command. The next command executes unconditionally after the previous one.
      Parameters:
      command - the next command
      Returns:
      this builder
    • redirect

      public PipelineBuilder redirect(Path file)
      Adds an output redirection (>) to the specified file.
      Parameters:
      file - the file to redirect output to
      Returns:
      this builder
    • append

      public PipelineBuilder append(Path file)
      Adds an append redirection (>>) to the specified file.
      Parameters:
      file - the file to append output to
      Returns:
      this builder
    • inputRedirect

      public PipelineBuilder inputRedirect(Path file)
      Adds an input redirection (<) from the specified file.
      Parameters:
      file - the file to read input from
      Returns:
      this builder
    • stderrRedirect

      public PipelineBuilder stderrRedirect(Path file)
      Adds a stderr redirection (2>) to the specified file.
      Parameters:
      file - the file to redirect stderr to
      Returns:
      this builder
    • combinedRedirect

      public PipelineBuilder combinedRedirect(Path file)
      Adds a combined stdout+stderr redirection (&>) to the specified file.
      Parameters:
      file - the file to redirect both streams to
      Returns:
      this builder
    • background

      public PipelineBuilder background()
      Marks this pipeline for background execution.
      Returns:
      this builder
    • build

      public Pipeline build()
      Builds the pipeline.
      Returns:
      the constructed pipeline