Update readme

This commit is contained in:
crschnick
2023-02-28 14:22:49 +00:00
parent 1bde4c8909
commit d5a7e2fb64
17 changed files with 91 additions and 47 deletions

View File

@@ -18,11 +18,19 @@ public class FileNames {
}
public static String getFileName(String file) {
if (file.isEmpty()) {
return "";
}
var split = file.split("[\\\\/]");
if (split.length == 0) {
return "";
}
var components = Arrays.stream(split).filter(s -> !s.isEmpty()).toList();
if (components.size() == 0) {
return "";
}
return components.get(components.size() - 1);
}

View File

@@ -4,12 +4,12 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
import io.xpipe.core.process.ProcessControlProvider;
import io.xpipe.core.process.ShellDialects;
import io.xpipe.core.process.ShellProcessControl;
import io.xpipe.core.store.*;
import io.xpipe.core.store.ConnectionFileSystem;
import io.xpipe.core.store.FileSystem;
import io.xpipe.core.store.FileSystemStore;
import io.xpipe.core.store.ShellStore;
import io.xpipe.core.util.JacksonizedValue;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
@JsonTypeName("local")
@@ -43,17 +43,6 @@ public class LocalStore extends JacksonizedValue implements ShellStore {
return LocalStore.this;
}
@Override
public InputStream openInput(String file) throws Exception {
var p = wrap(file);
return Files.newInputStream(p);
}
@Override
public OutputStream openOutput(String file) throws Exception {
var p = wrap(file);
return Files.newOutputStream(p);
}
private Path wrap(String file) {
for (var e : System.getenv().entrySet()) {

View File

@@ -49,10 +49,16 @@ public interface CommandProcessControl extends ProcessControl {
public String readOrThrow() throws Exception;
public default boolean discardAndCheckExit() {
public default boolean discardAndCheckExit() throws ProcessOutputException {
try {
discardOrThrow();
return true;
} catch (ProcessOutputException ex) {
if (ex.isTimeOut()) {
throw ex;
}
return false;
} catch (Exception ex) {
return false;
}

View File

@@ -25,4 +25,8 @@ public class ProcessOutputException extends Exception {
this.exitCode = exitCode;
this.output = output;
}
public boolean isTimeOut() {
return exitCode == -1;
}
}

View File

@@ -17,6 +17,14 @@ public interface ShellDialect {
return "cd \"" + directory + "\"";
}
default String getPushdCommand(String directory){
return "pushd \"" + directory + "\"";
}
default String getPopdCommand(){
return "popd";
}
String getScriptFileEnding();
String addInlineVariablesToCommand(Map<String, String> variables, String command);
@@ -39,8 +47,6 @@ public interface ShellDialect {
.collect(Collectors.joining(" "));
}
void disableHistory(ShellProcessControl pc) throws Exception;
default String getExitCommand() {
return "exit";
}

View File

@@ -0,0 +1,10 @@
package io.xpipe.core.process;
import lombok.Value;
@Value
public class ShellProperties {
ShellDialect dialect;
boolean tty;
}