mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-08-23 01:36:33 +00:00
More shell fixes
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package io.xpipe.core.process;
|
||||
|
||||
import io.xpipe.core.util.FailableBiFunction;
|
||||
import io.xpipe.core.util.FailableFunction;
|
||||
import lombok.NonNull;
|
||||
|
||||
@@ -29,7 +28,7 @@ public abstract class ProcessControlProvider {
|
||||
public static ShellControl createSub(
|
||||
ShellControl parent,
|
||||
@NonNull FailableFunction<ShellControl, String, Exception> commandFunction,
|
||||
FailableBiFunction<ShellControl, String, String, Exception> terminalCommand) {
|
||||
ShellControl.TerminalOpenFunction terminalCommand) {
|
||||
return INSTANCES.stream()
|
||||
.map(localProcessControlProvider ->
|
||||
localProcessControlProvider.sub(parent, commandFunction, terminalCommand))
|
||||
@@ -61,7 +60,7 @@ public abstract class ProcessControlProvider {
|
||||
public abstract ShellControl sub(
|
||||
ShellControl parent,
|
||||
@NonNull FailableFunction<ShellControl, String, Exception> commandFunction,
|
||||
FailableBiFunction<ShellControl, String, String, Exception> terminalCommand);
|
||||
ShellControl.TerminalOpenFunction terminalCommand);
|
||||
|
||||
public abstract CommandControl command(
|
||||
ShellControl parent,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package io.xpipe.core.process;
|
||||
|
||||
import io.xpipe.core.util.FailableBiFunction;
|
||||
import io.xpipe.core.util.FailableFunction;
|
||||
import io.xpipe.core.util.SecretValue;
|
||||
import lombok.NonNull;
|
||||
@@ -73,16 +72,53 @@ public interface ShellControl extends ProcessControl {
|
||||
SecretValue getElevationPassword();
|
||||
|
||||
default ShellControl subShell(@NonNull ShellDialect type) {
|
||||
return subShell(p -> type.getOpenCommand(), null).elevationPassword(getElevationPassword());
|
||||
return subShell(p -> type.getOpenCommand(), new TerminalOpenFunction() {
|
||||
@Override
|
||||
public boolean changesEnvironment() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String prepare(ShellControl sc, String command) throws Exception {
|
||||
return command;
|
||||
}
|
||||
}).elevationPassword(getElevationPassword());
|
||||
}
|
||||
|
||||
interface TerminalOpenFunction {
|
||||
|
||||
boolean changesEnvironment();
|
||||
|
||||
String prepare(ShellControl sc, String command) throws Exception;
|
||||
}
|
||||
|
||||
default ShellControl identicalSubShell() {
|
||||
return subShell(p -> p.getShellDialect().getOpenCommand(), null)
|
||||
return subShell(p -> p.getShellDialect().getOpenCommand(), new TerminalOpenFunction() {
|
||||
@Override
|
||||
public boolean changesEnvironment() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String prepare(ShellControl sc, String command) throws Exception {
|
||||
return command;
|
||||
}
|
||||
})
|
||||
.elevationPassword(getElevationPassword());
|
||||
}
|
||||
|
||||
default ShellControl subShell(@NonNull String command) {
|
||||
return subShell(processControl -> command, null);
|
||||
return subShell(processControl -> command, new TerminalOpenFunction() {
|
||||
@Override
|
||||
public boolean changesEnvironment() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String prepare(ShellControl sc, String command) throws Exception {
|
||||
return command;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
default <T> T enforceDialect(@NonNull ShellDialect type, Function<ShellControl, T> sc) throws Exception {
|
||||
@@ -97,7 +133,7 @@ public interface ShellControl extends ProcessControl {
|
||||
|
||||
ShellControl subShell(
|
||||
FailableFunction<ShellControl, String, Exception> command,
|
||||
FailableBiFunction<ShellControl, String, String, Exception> terminalCommand);
|
||||
TerminalOpenFunction terminalCommand);
|
||||
|
||||
void executeLine(String command) throws Exception;
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ public interface ShellDialect {
|
||||
|
||||
String getOpenCommand();
|
||||
|
||||
String prepareTerminalInitFileOpenCommand(ShellControl parent, String file) throws Exception;
|
||||
String prepareTerminalInitFileOpenCommand(ShellDialect parentDialect, ShellControl sc, String file) throws Exception;
|
||||
|
||||
String runScript(String file);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user