mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-08-13 21:11:11 +00:00
Preview executed commands in connection creation window
This commit is contained in:
@@ -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";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user