mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-04-24 16:40:58 -04:00
Merge branch 1.7.3 into master
This commit is contained in:
35
core/src/main/java/io/xpipe/core/process/ScriptSnippet.java
Normal file
35
core/src/main/java/io/xpipe/core/process/ScriptSnippet.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package io.xpipe.core.process;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
|
||||
public interface ScriptSnippet {
|
||||
|
||||
@Getter
|
||||
public static enum ExecutionType {
|
||||
@JsonProperty("dumbOnly")
|
||||
DUMB_ONLY("dumbOnly"),
|
||||
@JsonProperty("terminalOnly")
|
||||
TERMINAL_ONLY("terminalOnly"),
|
||||
@JsonProperty("both")
|
||||
BOTH("both");
|
||||
|
||||
private final String id;
|
||||
|
||||
ExecutionType(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public boolean runInDumb() {
|
||||
return this == DUMB_ONLY || this == BOTH;
|
||||
}
|
||||
|
||||
public boolean runInTerminal() {
|
||||
return this == TERMINAL_ONLY || this == BOTH;
|
||||
}
|
||||
}
|
||||
|
||||
String content(ShellControl shellControl);
|
||||
|
||||
ExecutionType executionType();
|
||||
}
|
||||
@@ -15,6 +15,8 @@ import java.util.function.Predicate;
|
||||
|
||||
public interface ShellControl extends ProcessControl {
|
||||
|
||||
List<ScriptSnippet> getInitCommands();
|
||||
|
||||
ShellControl withTargetTerminalShellDialect(ShellDialect d);
|
||||
|
||||
ShellDialect getTargetTerminalShellDialect();
|
||||
@@ -153,11 +155,7 @@ public interface ShellControl extends ProcessControl {
|
||||
}
|
||||
ShellControl elevationPassword(FailableSupplier<SecretValue> value);
|
||||
|
||||
ShellControl initWith(String cmds);
|
||||
|
||||
ShellControl initWithDumb(String cmds);
|
||||
|
||||
ShellControl initWithTerminal(String cmds);
|
||||
ShellControl initWith(ScriptSnippet snippet);
|
||||
|
||||
ShellControl additionalTimeout(int ms);
|
||||
|
||||
|
||||
@@ -26,6 +26,10 @@ public interface ShellDialect {
|
||||
.collect(Collectors.joining(" "));
|
||||
}
|
||||
|
||||
default boolean isSupportedShell() {
|
||||
return true;
|
||||
}
|
||||
|
||||
default boolean isSelectable() {
|
||||
return true;
|
||||
}
|
||||
@@ -40,7 +44,7 @@ public interface ShellDialect {
|
||||
|
||||
String getCatchAllVariable();
|
||||
|
||||
CommandControl queryVersion(ShellControl shellControl);
|
||||
String queryVersion(ShellControl shellControl) throws Exception;
|
||||
|
||||
CommandControl prepareUserTempDirectory(ShellControl shellControl, String directory);
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ public class ShellDialects {
|
||||
public static ShellDialect ZSH;
|
||||
public static ShellDialect CSH;
|
||||
public static ShellDialect FISH;
|
||||
public static ShellDialect UNSUPPORTED;
|
||||
public static ShellDialect CISCO;
|
||||
|
||||
public static class Loader implements ModuleLayerLoader {
|
||||
|
||||
@@ -40,6 +42,8 @@ public class ShellDialects {
|
||||
CSH = byName("csh");
|
||||
ASH = byName("ash");
|
||||
SH = byName("sh");
|
||||
UNSUPPORTED = byName("unsupported");
|
||||
CISCO = byName("cisco");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package io.xpipe.core.process;
|
||||
|
||||
import lombok.NonNull;
|
||||
|
||||
public class SimpleScriptSnippet implements ScriptSnippet {
|
||||
|
||||
@NonNull
|
||||
private final String content;
|
||||
@NonNull
|
||||
private final ExecutionType executionType;
|
||||
|
||||
public SimpleScriptSnippet(@NonNull String content, @NonNull ExecutionType executionType) {
|
||||
this.content = content;
|
||||
this.executionType = executionType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String content(ShellControl shellControl) {
|
||||
return content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExecutionType executionType() {
|
||||
return executionType;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user