Module id.xfunction

Class XExec

Object
XExec

public class XExec extends Object
Additions to standard java.lang.ProcessBuilder
  • Constructor Details

    • XExec

      public XExec(String... cmd)
      Constructor which accepts the command to run. First item of the array should be the command itself and the rest items are arguments of it.
    • XExec

      public XExec(List<String> cmd)
      Constructor which accepts the command to run. First item of the list should be the command itself and the rest items are arguments of it.
    • XExec

      public XExec(String cmd)
      Constructor which accepts the full command line to run.

      It supports quotes so command like "ls \"/tmp/Program Files\"" will be processed like "ls" "/tmp/Program Files" instead of "ls" "/tmp/Program" "Files"

  • Method Details

    • withInput

      public XExec withInput(Stream<String> input)
      Given input will be sent to command's stdin.
    • withDirectory

      public XExec withDirectory(String workingDirectory)
      Sets the working directory for the process
    • withDirectory

      public XExec withDirectory(Path workingDirectory)
      Sets the working directory for the process
    • withEnvironmentVariables

      public XExec withEnvironmentVariables(Map<String,String> vars)
      Adds following variables into environment
    • withMaskedSecrets

      public XExec withMaskedSecrets(String... secrets)
      List of secrets which will be masked in the command output (both stdout, stderr)
    • getCommand

      public String[] getCommand()
    • getProcessBuilder

      public ProcessBuilder getProcessBuilder()
    • start

      public XProcess start()
      Run the command with given input if any