Merge branch better-commands

This commit is contained in:
crschnick
2024-04-01 07:25:06 +00:00
parent 10ef67a6ec
commit d3c173dbcd
18 changed files with 185 additions and 237 deletions

View File

@@ -210,7 +210,11 @@ public class CommandBuilder {
return this;
}
public String buildCommandBase(ShellControl sc) throws Exception {
public String buildBase(ShellControl sc) throws Exception {
return String.join(" ", buildBaseParts(sc));
}
public List<String> buildBaseParts(ShellControl sc) throws Exception {
countDown = CountDown.of();
uuid = UUID.randomUUID();
@@ -227,11 +231,11 @@ public class CommandBuilder {
list.add(evaluate);
}
return String.join(" ", list);
return list;
}
public String buildString(ShellControl sc) throws Exception {
var s = buildCommandBase(sc);
public String buildFull(ShellControl sc) throws Exception {
var s = buildBase(sc);
LinkedHashMap<String, String> map = new LinkedHashMap<>();
for (var e : environmentVariables.entrySet()) {
var v = e.getValue().evaluate(sc);
@@ -239,7 +243,7 @@ public class CommandBuilder {
map.put(e.getKey(), v);
}
}
return sc.getShellDialect().addInlineVariablesToCommand(map, s);
return sc.getShellDialect().assembleCommand(s, map);
}
public CommandControl build(ShellControl sc) {

View File

@@ -16,6 +16,8 @@ import java.util.stream.Stream;
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
public interface ShellDialect {
CommandBuilder launchAsnyc(CommandBuilder cmd);
default String getLicenseFeatureId() {
return null;
}
@@ -80,7 +82,7 @@ public interface ShellDialect {
String getScriptFileEnding();
String addInlineVariablesToCommand(Map<String, String> variables, String command);
String assembleCommand(String command, Map<String, String> variables);
Stream<FileSystem.FileEntry> listFiles(FileSystem fs, ShellControl control, String dir) throws Exception;