Preview executed commands in connection creation window

This commit is contained in:
crschnick
2023-06-13 16:40:52 +00:00
parent 6d4e800333
commit 67654f3005
17 changed files with 168 additions and 70 deletions
@@ -57,6 +57,14 @@ public abstract class ProcessControlProvider {
.orElseThrow();
}
public static String createSshPreview(Object sshStore) {
return INSTANCES.stream()
.map(localProcessControlProvider -> localProcessControlProvider.createSshControlPreview(sshStore))
.filter(Objects::nonNull)
.findFirst()
.orElseThrow();
}
public abstract ShellControl sub(
ShellControl parent,
@NonNull FailableFunction<ShellControl, String, Exception> commandFunction,
@@ -70,4 +78,6 @@ public abstract class ProcessControlProvider {
public abstract ShellControl createLocalProcessControl(boolean stoppable);
public abstract ShellControl createSshControl(Object sshStore);
public abstract String createSshControlPreview(Object sshStore);
}
@@ -197,7 +197,7 @@ public interface ShellControl extends ProcessControl {
default CommandControl command(List<String> command) {
return command(
shellProcessControl -> shellProcessControl.getShellDialect().flatten(command));
shellProcessControl -> ShellDialect.flatten(command));
}
void exitAndWait() throws IOException;
@@ -15,6 +15,16 @@ import java.util.stream.Stream;
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
public interface ShellDialect {
public static String flatten(List<String> command) {
return command.stream()
.map(s -> s.contains(" ")
&& !(s.startsWith("\"") && s.endsWith("\""))
&& !(s.startsWith("'") && s.endsWith("'"))
? "\"" + s + "\""
: s)
.collect(Collectors.joining(" "));
}
CommandControl prepareTempDirectory(ShellControl shellControl, String directory);
String initFileName(ShellControl sc) throws Exception;
@@ -67,16 +77,6 @@ public interface ShellDialect {
String prepareScriptContent(String content);
default String flatten(List<String> command) {
return command.stream()
.map(s -> s.contains(" ")
&& !(s.startsWith("\"") && s.endsWith("\""))
&& !(s.startsWith("'") && s.endsWith("'"))
? "\"" + s + "\""
: s)
.collect(Collectors.joining(" "));
}
default String getExitCommand() {
return "exit";
}