Class ProcessConfig
java.lang.Object
cloud.opencode.base.core.process.ProcessConfig
ProcessConfig - Configuration for process execution
ProcessConfig - 进程执行配置
Immutable configuration object built via the ProcessConfig.Builder pattern.
Controls command, working directory, environment variables, timeout,
stream redirection, and IO inheritance.
通过 ProcessConfig.Builder 模式构建的不可变配置对象。
控制命令、工作目录、环境变量、超时时间、流重定向和 IO 继承。
Usage Examples | 使用示例:
ProcessConfig config = ProcessConfig.builder("ls", "-la")
.workingDirectory(Path.of("/tmp"))
.environment("LANG", "en_US.UTF-8")
.timeout(Duration.ofSeconds(30))
.build();
ProcessResult result = ProcessManager.execute(config);
Thread Safety | 线程安全: Instances are immutable and thread-safe. 实例是不可变的,线程安全。
- Since:
- JDK 25, opencode-base-core V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic ProcessConfig.BuilderCreates a new builder with the given command.static ProcessConfig.BuilderCreates a new builder with the given command list.command()Returns the command and arguments.Returns additional environment variables.booleanReturns whether the process should inherit the parent's IO.booleanReturns whether stderr should be merged into stdout.Returns the file to redirect stderr to, ornullfor in-memory capture.Returns the file to redirect stdout to, ornullfor in-memory capture.timeout()Returns the execution timeout, ornullfor no timeout.toString()Returns the working directory, ornullto inherit from the parent process.
-
Method Details
-
builder
Creates a new builder with the given command. 以给定命令创建新的构建器。- Parameters:
command- the command and arguments - 命令和参数- Returns:
- a new builder - 新的构建器
- Throws:
IllegalArgumentException- if command is empty - 若命令为空
-
builder
Creates a new builder with the given command list. 以给定命令列表创建新的构建器。- Parameters:
command- the command and arguments - 命令和参数- Returns:
- a new builder - 新的构建器
- Throws:
IllegalArgumentException- if command is empty - 若命令为空
-
command
-
workingDirectory
Returns the working directory, ornullto inherit from the parent process. 返回工作目录,若为null则继承父进程。- Returns:
- the working directory, or null - 工作目录,或 null
-
environment
-
timeout
Returns the execution timeout, ornullfor no timeout. 返回执行超时时间,若为null则无超时。- Returns:
- the timeout, or null - 超时时间,或 null
-
redirectErrorStream
public boolean redirectErrorStream()Returns whether stderr should be merged into stdout. 返回是否将 stderr 合并到 stdout。- Returns:
- true if error stream is redirected - 若错误流被重定向则为 true
-
stdoutFile
Returns the file to redirect stdout to, ornullfor in-memory capture. 返回 stdout 重定向的文件,若为null则在内存中捕获。- Returns:
- stdout file, or null - stdout 文件,或 null
-
stderrFile
Returns the file to redirect stderr to, ornullfor in-memory capture. 返回 stderr 重定向的文件,若为null则在内存中捕获。- Returns:
- stderr file, or null - stderr 文件,或 null
-
inheritIO
public boolean inheritIO()Returns whether the process should inherit the parent's IO. 返回进程是否继承父进程的 IO。- Returns:
- true if inheriting IO - 若继承 IO 则为 true
-
toString
-