public final class CommandContext extends Object
This class provides several static factory methods for creating common contexts. For more complex contexts that set multiple properties, use the builder.
Instances of this class are immutable.
Modifier and Type | Class and Description |
---|---|
static class |
CommandContext.Builder
Builds
CommandContext objects. |
Modifier and Type | Method and Description |
---|---|
static CommandContext.Builder |
builder()
Returns a new
CommandContext builder. |
static CommandContext |
defaultContext()
Returns the default context object.
|
CommandEnvironment |
getEnvironment()
Returns a copy of this context's
CommandEnvironment . |
Predicate<Integer> |
getExitStatusVerifier()
Returns the predicate this context uses to verify the exit status of
commands.
|
Optional<Integer> |
getStderrWindowSize()
Returns this context's error window.
|
Optional<Integer> |
getStdoutWindowSize()
Returns this context's output window.
|
Optional<UniformPath> |
getWorkingDirectory()
Returns this context's working directory.
|
static CommandContext |
ignoreExitStatus()
Returns a context that ignores the exit status of commands.
|
static CommandContext |
requireExitStatus(int status)
Returns a context that requires commands exit with the given status.
|
static CommandContext |
withEnvironment(CommandEnvironment environment)
Returns a context that sets the given environment before commands
execute.
|
static CommandContext |
workingDirectory(Path path)
Returns a context that executes commands in the given directory.
|
static CommandContext |
workingDirectory(UniformPath path)
Returns a context that executes commands in the given directory.
|
public static CommandContext.Builder builder()
CommandContext
builder.public static CommandContext defaultContext()
0
.public static CommandContext ignoreExitStatus()
public static CommandContext requireExitStatus(int status)
status
- the required exit statusCommandContext.Builder.requireExitStatus(int)
public static CommandContext withEnvironment(CommandEnvironment environment)
environment
- the environmentCommandContext.Builder.environment(CommandEnvironment)
public static CommandContext workingDirectory(UniformPath path)
path
- the working directory pathCommandContext.Builder.workingDirectory(UniformPath)
public static CommandContext workingDirectory(Path path)
path
- the working directory pathCommandContext.Builder.workingDirectory(Path)
public CommandEnvironment getEnvironment()
CommandEnvironment
.public Predicate<Integer> getExitStatusVerifier()
public Optional<UniformPath> getWorkingDirectory()
Optional
is not present, this context uses the system-dependent
default working directory.public Optional<Integer> getStdoutWindowSize()
Optional
is
not present, the window size is unlimited.