Class NbCliDescriptor

java.lang.Object
uk.theretiredprogrammer.actionssupport.NbCliDescriptor

public class NbCliDescriptor extends Object
NbCLIExec implements both configuration of a CLI style command and also its execution. Builder style method chaining is provided for configuration includes both general configuration and input/output options. The CLI CommandArgs is processed to do limited parameter substitution, ${NODEPATH} is replaced with the node folder path.
  • Constructor Details

    • NbCliDescriptor

      public NbCliDescriptor(org.openide.filesystems.FileObject dir, String clicommand, String cliargs)
      Create the initial NbCLIExec object with the mandatory information. It can be further configured by use of the various builder style methods.
      Parameters:
      dir - The node folder - will be used as the working directory when executing this object.
      clicommand - the command to be run when executing this command.
      cliargs - the command arguements to use used when executing this command.
    • NbCliDescriptor

      public NbCliDescriptor()
      Create the empty NbCLIExec object. It can be further configured by use of the various builder style methods.
    • NbCliDescriptor

      public NbCliDescriptor(NbCliDescriptor source)
      Clone a NbCLIExec object.
      Parameters:
      source - the object to clone from.
  • Method Details

    • directory

      public NbCliDescriptor directory(org.openide.filesystems.FileObject dir)
      Define the working folder for process execution. This is typically the Node folder.
      Parameters:
      dir - the folder
      Returns:
      this object
    • cliCommand

      public NbCliDescriptor cliCommand(String clicommand)
      Define the cli command to be used for process execution.
      Parameters:
      clicommand - the cli command
      Returns:
      this object
    • cliArgs

      public NbCliDescriptor cliArgs(String cliargs)
      Define the cli arguements to be used for process execution.
      Parameters:
      cliargs - the cli arguements
      Returns:
      this object
    • preprocessing

      public NbCliDescriptor preprocessing(Consumer<org.netbeans.api.io.OutputWriter> preprocessing)
      Define a method to be executed prior to the main Execute Process running. This method will be executed as part of the exec method, if the OutputWindow is to be used for input or output.
      Parameters:
      preprocessing - the pre processing method
      Returns:
      this object
    • postprocessing

      public NbCliDescriptor postprocessing(Consumer<org.netbeans.api.io.OutputWriter> postprocessing)
      Define a method to be executed after to the main Execute Process running. This method will be executed as part of the exec method, if the OutputWindow is to be used for input or output.
      Parameters:
      postprocessing - the post processing method
      Returns:
      this object
    • ioTabName

      public NbCliDescriptor ioTabName(String tabname)
      Define the tab to be used, if the Output Window is to be used for input or output.
      Parameters:
      tabname - tabname to be used/reused.
      Returns:
      this object
    • ioTabClear

      public NbCliDescriptor ioTabClear()
      Clear the IOTab before each usage.
      Returns:
      this object
    • addCommands

      public NbCliDescriptor addCommands(Map<String,uk.theretiredprogrammer.actionssupportimplementation.IOCOMMANDS.CommandPair> commands)
      Add a set of commands to the allowed commands.
      Parameters:
      commands - the map containing the command definitions
      Returns:
      this object
    • addCommand

      public NbCliDescriptor addCommand(String command, Runnable action, boolean terminating)
      Add a command to the allowed commands.
      Parameters:
      command - the command word
      action - the command action
      terminating - true if this command is a terminating command - ie after it is executed it will stop further command processing.
      Returns:
      this object
    • addKillCommand

      public NbCliDescriptor addKillCommand(String command)
      Add a Kill command to the allowed commands(to KILL the external process).
      Parameters:
      command - the command word
      Returns:
      this object
    • stdinIgnore

      public NbCliDescriptor stdinIgnore()
      Do not handle STDIN.
      Returns:
      this object
    • stdinEmpty

      public NbCliDescriptor stdinEmpty()
      Pass an empty file to STDIN;
      Returns:
      this object
    • stdinFromFile

      public NbCliDescriptor stdinFromFile(org.openide.filesystems.FileObject fileobject)
      Pass a FileObject to STDIN.
      Parameters:
      fileobject - the source
      Returns:
      this object
    • stdinFromFile

      public NbCliDescriptor stdinFromFile(File file)
      Pass a File to STDIN.
      Parameters:
      file - the source
      Returns:
      this object
    • stdinFromFile

      public NbCliDescriptor stdinFromFile(org.openide.loaders.DataObject dataobject)
      Pass a DataObject to STDIN.
      Parameters:
      dataobject - the source
      Returns:
      this object
    • stdinFromFile

      public NbCliDescriptor stdinFromFile(InputStream instream)
      Pass an InputStream to STDIN.
      Parameters:
      instream - the source
      Returns:
      this object
    • stdinFromFile

      public NbCliDescriptor stdinFromFile(BufferedReader reader)
      Pass a Reader to STDIN.
      Parameters:
      reader - the source
      Returns:
      this object
    • stdoutIgnore

      public NbCliDescriptor stdoutIgnore()
      Do not handle STDOUT.
      Returns:
      this object
    • stdoutDiscard

      public NbCliDescriptor stdoutDiscard()
      Discard the STDOUT generated.
      Returns:
      this object
    • stdoutToIO

      public NbCliDescriptor stdoutToIO()
      Pass the STDOUT to the IOTab.
      Returns:
      this object
    • stdoutToFile

      public NbCliDescriptor stdoutToFile(org.openide.filesystems.FileObject fileobject)
      Pass the STDOUT to a FileObject.
      Parameters:
      fileobject - the target
      Returns:
      this object
    • stdoutToFile

      public NbCliDescriptor stdoutToFile(File file)
      Pass the STDOUT to a File.
      Parameters:
      file - the target
      Returns:
      this object
    • stdoutToFile

      public NbCliDescriptor stdoutToFile(org.openide.loaders.DataObject dataobject)
      Pass the STDOUT to a DataObject.
      Parameters:
      dataobject - the target
      Returns:
      this object
    • stdoutToFile

      public NbCliDescriptor stdoutToFile(OutputStream outstream)
      Pass the STDOUT to an OutputStream.
      Parameters:
      outstream - the target
      Returns:
      this object
    • stdoutToFile

      public NbCliDescriptor stdoutToFile(Writer writer)
      Pass the STDOUT to a Writer.
      Parameters:
      writer - the target
      Returns:
      this object
    • stderrIgnore

      public NbCliDescriptor stderrIgnore()
      Do not handle STDERR.
      Returns:
      this object
    • stderrDiscard

      public NbCliDescriptor stderrDiscard()
      Discard the STDERR generated.
      Returns:
      this object
    • stderrToIO

      public NbCliDescriptor stderrToIO()
      Pass the STDERR to the IOTab.
      Returns:
      this object
    • stderrToFile

      public NbCliDescriptor stderrToFile(org.openide.filesystems.FileObject fileobject)
      Pass the STDERR to a FileObject.
      Parameters:
      fileobject - the target
      Returns:
      this object
    • stderrToFile

      public NbCliDescriptor stderrToFile(File file)
      Pass the STDERR to a File.
      Parameters:
      file - the target
      Returns:
      this object
    • stderrToFile

      public NbCliDescriptor stderrToFile(org.openide.loaders.DataObject dataobject)
      Pass the STDERR to a DataObject.
      Parameters:
      dataobject - the target
      Returns:
      this object
    • stderrToFile

      public NbCliDescriptor stderrToFile(OutputStream outstream)
      Pass the STDERR to an OutputStream.
      Parameters:
      outstream - the target
      Returns:
      this object
    • stderrToFile

      public NbCliDescriptor stderrToFile(Writer writer)
      Pass the STDERR to a Writer.
      Parameters:
      writer - the target
      Returns:
      this object
    • exec

      public void exec(String startmessage)
      Execute the NbCliDescription - will run the defined command/arguements in an external process. will create any necessary threads to manage data to and from that process. can create (or reuse) an IOTab to optionally display the process's STDERR and STDOUT. can create a simple command system taking input from IOTab.
      Parameters:
      startmessage - optional message which can be written to the IO Tab prior to starting the external process (set to null to ignore message writing)