Skip to content

Commit

Permalink
chore: Cosmetic changes on JBang commands
Browse files Browse the repository at this point in the history
  • Loading branch information
christophd committed Nov 17, 2023
1 parent 0fa32da commit ca6ee84
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,16 @@
*/
package org.citrusframework.yaks.jbang.commands;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import com.fasterxml.jackson.databind.JsonNode;
import com.github.freva.asciitable.AsciiTable;
import com.github.freva.asciitable.Column;
import com.github.freva.asciitable.HorizontalAlign;
import com.github.freva.asciitable.OverflowBehaviour;
import main.YaksJBang;
import org.citrusframework.jbang.JsonSupport;
import org.citrusframework.util.FileUtils;
import org.citrusframework.yaks.jbang.YaksJBangMain;
import picocli.CommandLine;
import picocli.CommandLine.Command;
Expand Down Expand Up @@ -140,21 +134,6 @@ protected int sortRow(Row o1, Row o2) {
}
}

private JsonNode loadStatus(long pid) {
try {
File f = getStatusFile("" + pid);
if (f != null && f.exists()) {
try (FileInputStream fis = new FileInputStream(f)) {
String text = FileUtils.readToString(fis);
return JsonSupport.json().reader().readTree(text);
}
}
} catch (IOException e) {
// ignore
}
return null;
}

static long extractSince(ProcessHandle ph) {
long since = 0;
if (ph.info().startInstant().isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,19 @@ public YaksJBangMain getMain() {
}

public File getStatusFile(String pid) {
if (yaksDir == null) {
yaksDir = new File(System.getProperty("user.home"), ".yaks");
}
return new File(yaksDir, pid + "-status.json");
return new File(getYaksDir(), pid + "-status.json");
}

public File getOutputFile(String pid) {
return new File(getYaksDir(), pid + "-output.json");
}

private File getYaksDir() {
if (yaksDir == null) {
yaksDir = new File(System.getProperty("user.home"), ".yaks");
}
return new File(yaksDir, pid + "-output.json");

return yaksDir;
}

}

0 comments on commit ca6ee84

Please sign in to comment.