Skip to content

Commit 38d5ebf

Browse files
committed
feat(runtime): add per-execution CLI context
1 parent 735426c commit 38d5ebf

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package io.github.easy4j.opencode.cli;
2+
3+
import lombok.Data;
4+
5+
import java.util.LinkedHashMap;
6+
import java.util.Map;
7+
8+
/**
9+
* Overrides that apply to one CLI child-process execution only.
10+
*
11+
* @author <a href="https://github.com/loong10k">Loong Wan</a>
12+
* @since 3.0.0
13+
*/
14+
@Data
15+
public class OpenCodeCliExecutionContext {
16+
17+
/** Whether the child starts from the parent JVM environment. */
18+
private boolean inheritParentEnvironment = true;
19+
20+
/** Per-execution environment overrides. */
21+
private final Map<String, String> environment = new LinkedHashMap<>();
22+
23+
/** Optional per-execution working directory override. */
24+
private String workingDirectory;
25+
26+
public OpenCodeCliExecutionContext environment(String name, String value) {
27+
if (value == null) {
28+
environment.remove(name);
29+
} else {
30+
environment.put(name, value);
31+
}
32+
return this;
33+
}
34+
35+
public OpenCodeCliExecutionContext inheritParentEnvironment(boolean value) {
36+
this.inheritParentEnvironment = value;
37+
return this;
38+
}
39+
40+
public OpenCodeCliExecutionContext workingDirectory(String value) {
41+
this.workingDirectory = value;
42+
return this;
43+
}
44+
}

0 commit comments

Comments
 (0)