Various small improvements

This commit is contained in:
crschnick
2023-05-27 13:35:47 +00:00
parent 59d0706129
commit e7b5d7e9ee
7 changed files with 29 additions and 20 deletions

View File

@@ -80,6 +80,8 @@ public interface CommandControl extends ProcessControl {
void accumulateStderr(Consumer<String> con);
public byte[] readRawBytesOrThrow() throws Exception;
public String readOrThrow() throws Exception;
public default boolean discardAndCheckExit() throws ProcessOutputException {

View File

@@ -48,6 +48,12 @@ public interface ShellControl extends ProcessControl {
""", script));
}
default byte[] executeSimpleRawBytesCommand(String command) throws Exception {
try (CommandControl c = command(command).start()) {
return c.readRawBytesOrThrow();
}
}
default String executeSimpleStringCommand(String command) throws Exception {
try (CommandControl c = command(command).start()) {
return c.readOrThrow();