Class NbCliDescriptor
java.lang.Object
uk.theretiredprogrammer.actionssupport.NbCliDescriptor
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 Summary
ConstructorsConstructorDescriptionCreate the empty NbCLIExec object.NbCliDescriptor(org.openide.filesystems.FileObject dir, String clicommand, String cliargs) Create the initial NbCLIExec object with the mandatory information.NbCliDescriptor(NbCliDescriptor source) Clone a NbCLIExec object. -
Method Summary
Modifier and TypeMethodDescriptionaddCommand(String command, Runnable action, boolean terminating) Add a command to the allowed commands.addCommands(Map<String, uk.theretiredprogrammer.actionssupportimplementation.IOCOMMANDS.CommandPair> commands) Add a set of commands to the allowed commands.addKillCommand(String command) Add a Kill command to the allowed commands(to KILL the external process).Define the cli arguements to be used for process execution.cliCommand(String clicommand) Define the cli command to be used for process execution.directory(org.openide.filesystems.FileObject dir) Define the working folder for process execution.voidExecute the NbCliDescription - will run the defined command/arguements in an external process.Clear the IOTab before each usage.Define the tab to be used, if the Output Window is to be used for input or output.postprocessing(Consumer<org.netbeans.api.io.OutputWriter> postprocessing) Define a method to be executed after to the main Execute Process running.preprocessing(Consumer<org.netbeans.api.io.OutputWriter> preprocessing) Define a method to be executed prior to the main Execute Process running.Discard the STDERR generated.Do not handle STDERR.stderrToFile(File file) Pass the STDERR to a File.stderrToFile(OutputStream outstream) Pass the STDERR to an OutputStream.stderrToFile(Writer writer) Pass the STDERR to a Writer.stderrToFile(org.openide.filesystems.FileObject fileobject) Pass the STDERR to a FileObject.stderrToFile(org.openide.loaders.DataObject dataobject) Pass the STDERR to a DataObject.Pass the STDERR to the IOTab.Pass an empty file to STDIN;stdinFromFile(BufferedReader reader) Pass a Reader to STDIN.stdinFromFile(File file) Pass a File to STDIN.stdinFromFile(InputStream instream) Pass an InputStream to STDIN.stdinFromFile(org.openide.filesystems.FileObject fileobject) Pass a FileObject to STDIN.stdinFromFile(org.openide.loaders.DataObject dataobject) Pass a DataObject to STDIN.Do not handle STDIN.Discard the STDOUT generated.Do not handle STDOUT.stdoutToFile(File file) Pass the STDOUT to a File.stdoutToFile(OutputStream outstream) Pass the STDOUT to an OutputStream.stdoutToFile(Writer writer) Pass the STDOUT to a Writer.stdoutToFile(org.openide.filesystems.FileObject fileobject) Pass the STDOUT to a FileObject.stdoutToFile(org.openide.loaders.DataObject dataobject) Pass the STDOUT to a DataObject.Pass the STDOUT to the IOTab.
-
Constructor Details
-
NbCliDescriptor
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
Clone a NbCLIExec object.- Parameters:
source- the object to clone from.
-
-
Method Details
-
directory
Define the working folder for process execution. This is typically the Node folder.- Parameters:
dir- the folder- Returns:
- this object
-
cliCommand
Define the cli command to be used for process execution.- Parameters:
clicommand- the cli command- Returns:
- this object
-
cliArgs
Define the cli arguements to be used for process execution.- Parameters:
cliargs- the cli arguements- Returns:
- this object
-
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
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
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
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
Add a command to the allowed commands.- Parameters:
command- the command wordaction- the command actionterminating- true if this command is a terminating command - ie after it is executed it will stop further command processing.- Returns:
- this object
-
addKillCommand
Add a Kill command to the allowed commands(to KILL the external process).- Parameters:
command- the command word- Returns:
- this object
-
stdinIgnore
Do not handle STDIN.- Returns:
- this object
-
stdinEmpty
Pass an empty file to STDIN;- Returns:
- this object
-
stdinFromFile
Pass a FileObject to STDIN.- Parameters:
fileobject- the source- Returns:
- this object
-
stdinFromFile
Pass a File to STDIN.- Parameters:
file- the source- Returns:
- this object
-
stdinFromFile
Pass a DataObject to STDIN.- Parameters:
dataobject- the source- Returns:
- this object
-
stdinFromFile
Pass an InputStream to STDIN.- Parameters:
instream- the source- Returns:
- this object
-
stdinFromFile
Pass a Reader to STDIN.- Parameters:
reader- the source- Returns:
- this object
-
stdoutIgnore
Do not handle STDOUT.- Returns:
- this object
-
stdoutDiscard
Discard the STDOUT generated.- Returns:
- this object
-
stdoutToIO
Pass the STDOUT to the IOTab.- Returns:
- this object
-
stdoutToFile
Pass the STDOUT to a FileObject.- Parameters:
fileobject- the target- Returns:
- this object
-
stdoutToFile
Pass the STDOUT to a File.- Parameters:
file- the target- Returns:
- this object
-
stdoutToFile
Pass the STDOUT to a DataObject.- Parameters:
dataobject- the target- Returns:
- this object
-
stdoutToFile
Pass the STDOUT to an OutputStream.- Parameters:
outstream- the target- Returns:
- this object
-
stdoutToFile
Pass the STDOUT to a Writer.- Parameters:
writer- the target- Returns:
- this object
-
stderrIgnore
Do not handle STDERR.- Returns:
- this object
-
stderrDiscard
Discard the STDERR generated.- Returns:
- this object
-
stderrToIO
Pass the STDERR to the IOTab.- Returns:
- this object
-
stderrToFile
Pass the STDERR to a FileObject.- Parameters:
fileobject- the target- Returns:
- this object
-
stderrToFile
Pass the STDERR to a File.- Parameters:
file- the target- Returns:
- this object
-
stderrToFile
Pass the STDERR to a DataObject.- Parameters:
dataobject- the target- Returns:
- this object
-
stderrToFile
Pass the STDERR to an OutputStream.- Parameters:
outstream- the target- Returns:
- this object
-
stderrToFile
Pass the STDERR to a Writer.- Parameters:
writer- the target- Returns:
- this object
-
exec
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)
-