public class CommandTool extends Task<Object,ProcessResult>
| Modifier and Type | Field and Description |
|---|---|
protected List<Integer> |
allowedExitCodes |
protected CommandBuilder |
commandBuilder |
static File |
CURRENT_USER_DIR
Representation of current process working directory for purposes of
spawning new process
|
protected Map<String,String> |
environment |
protected ProcessInteraction |
interaction |
protected boolean |
isDaemon |
protected org.arquillian.spacelift.task.os.ProcessReference |
processRef |
protected File |
workingDirectory |
| Constructor and Description |
|---|
CommandTool() |
| Modifier and Type | Method and Description |
|---|---|
CommandTool |
addEnvironment(CharSequence... envVariables)
Adds a sequence of key, value environment variables to the default process environment
|
CommandTool |
addEnvironment(Map<? extends CharSequence,? extends CharSequence> envVariables)
Adds a map of key, value environment variables to the default process environment
|
CommandTool |
command(Command command)
Sets the command.
|
CommandTool |
command(CommandBuilder commandBuilder)
Sets the command.
|
Execution<ProcessResult> |
execute() |
CommandTool |
interaction(ProcessInteraction interaction)
Sets interaction for the command
|
CommandTool |
interaction(ProcessInteractionBuilder interactionBuilder)
Sets interaction for the command
|
CommandTool |
parameter(CharSequence parameter)
Adds a parameter to the command to be executed
|
CommandTool |
parameters(CharSequence... parameters)
Adds a list of parameters to the command to be executed
|
CommandTool |
parameters(List<? extends CharSequence> parameters)
Adds a list of parameters to the command to be executed
|
protected ProcessResult |
process(Object input) |
CommandTool |
programName(CharSequence programName)
Sets executable to be executed.
|
CommandTool |
runAsDaemon()
Indicates that command should be executed as daemon and survive JVM process.
|
CommandTool |
shouldExitWith(Integer... exitCodes)
Adds list of valid exit codes for the command.
|
CommandTool |
splitToParameters(CharSequence sequenceToBeParsed)
Splits
sequenceToBeParsed into list of parameters, using unescaped spaces as delimiters |
CommandTool |
workingDir(String workingDirectory)
Deprecated.
|
CommandTool |
workingDirectory(File workingDirectory) |
CommandTool |
workingDirectory(String workingDirectory)
Sets working directory for the command
|
getExecutionService, run, setExecutionService, setPreviousTask, then, thenpublic static final File CURRENT_USER_DIR
protected CommandBuilder commandBuilder
protected ProcessInteraction interaction
protected File workingDirectory
protected boolean isDaemon
protected org.arquillian.spacelift.task.os.ProcessReference processRef
public CommandTool programName(CharSequence programName) throws IllegalArgumentException
programName - program nameIllegalArgumentException - If program name is null or emptypublic CommandTool parameters(List<? extends CharSequence> parameters)
parameters - parameterspublic CommandTool parameters(CharSequence... parameters)
parameters - parameterspublic CommandTool parameter(CharSequence parameter)
parameter - parameterpublic CommandTool splitToParameters(CharSequence sequenceToBeParsed)
sequenceToBeParsed into list of parameters, using unescaped spaces as delimiterssequenceToBeParsed - string to be parsedpublic CommandTool interaction(ProcessInteraction interaction)
interaction - the interactionpublic CommandTool interaction(ProcessInteractionBuilder interactionBuilder)
interactionBuilder - the interactionpublic CommandTool command(Command command)
command - the commandpublic CommandTool command(CommandBuilder commandBuilder)
command - the commandpublic CommandTool shouldExitWith(Integer... exitCodes)
ExecutionException is thrown
By default, allowed exit code is set to 0
exitCodes - the exit codeothers - possible other codesExecutionExceptionpublic CommandTool workingDirectory(File workingDirectory) throws IllegalArgumentException
IllegalArgumentExceptionpublic CommandTool workingDirectory(String workingDirectory) throws IllegalArgumentException
workingDirectory - working directory, can be null to use current directory of running Java processIllegalArgumentException - if working directory does not exist@Deprecated public CommandTool workingDir(String workingDirectory) throws IllegalArgumentException
IllegalArgumentExceptionpublic CommandTool addEnvironment(Map<? extends CharSequence,? extends CharSequence> envVariables) throws IllegalArgumentException
envVariables - environment variables. Value might be null.IllegalArgumentExceptionpublic CommandTool addEnvironment(CharSequence... envVariables) throws IllegalArgumentException
envVariables - environment variables. Value might be null.IllegalArgumentException - If values do not form complete pairs or if key is nullpublic CommandTool runAsDaemon()
public Execution<ProcessResult> execute() throws ExecutionException
execute in class Task<Object,ProcessResult>ExecutionExceptionprotected ProcessResult process(Object input) throws Exception
process in class Task<Object,ProcessResult>ExceptionCopyright © 2017 JBoss by Red Hat. All rights reserved.