mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-22 07:30:24 +00:00
More environment variable fixes
This commit is contained in:
parent
215b78b75e
commit
cda3f0207e
1 changed files with 21 additions and 4 deletions
|
@ -15,14 +15,24 @@ public class CommandBuilder {
|
|||
|
||||
private final List<Element> elements = new ArrayList<>();
|
||||
@Getter
|
||||
private final Map<String, String> environmentVariables = new LinkedHashMap<>();
|
||||
private final Map<String, Element> environmentVariables = new LinkedHashMap<>();
|
||||
|
||||
public CommandBuilder envrironment(String k, String v) {
|
||||
public CommandBuilder fixedEnvrironment(String k, String v) {
|
||||
environmentVariables.put(k, new Fixed(v));
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandBuilder envrironment(String k, Element v) {
|
||||
environmentVariables.put(k, v);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandBuilder envrironment(Map<String, String> map) {
|
||||
public CommandBuilder fixedEnvrironment(Map<String, String> map) {
|
||||
map.forEach((s, s2) -> fixedEnvrironment(s, s2));
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandBuilder envrironment(Map<String, Element> map) {
|
||||
environmentVariables.putAll(map);
|
||||
return this;
|
||||
}
|
||||
|
@ -180,7 +190,14 @@ public class CommandBuilder {
|
|||
|
||||
public String build(ShellControl sc) throws Exception {
|
||||
var s = buildBase(sc);
|
||||
return sc.getShellDialect().addInlineVariablesToCommand(environmentVariables, s);
|
||||
LinkedHashMap<String, String> map = new LinkedHashMap<>();
|
||||
for (var e : environmentVariables.entrySet()) {
|
||||
var v = e.getValue().evaluate(sc);
|
||||
if (v != null) {
|
||||
map.put(e.getKey(), v);
|
||||
}
|
||||
}
|
||||
return sc.getShellDialect().addInlineVariablesToCommand(map, s);
|
||||
}
|
||||
|
||||
public CommandControl buildCommand(ShellControl sc) {
|
||||
|
|
Loading…
Reference in a new issue