From ca6ee848a6e8182759c9d34c866247886a27efff Mon Sep 17 00:00:00 2001 From: Christoph Deppisch Date: Fri, 17 Nov 2023 08:52:26 +0100 Subject: [PATCH] chore: Cosmetic changes on JBang commands --- .../yaks/jbang/commands/ListTests.java | 21 ------------------- .../yaks/jbang/commands/YaksCommand.java | 12 ++++++----- 2 files changed, 7 insertions(+), 26 deletions(-) diff --git a/java/tools/yaks-jbang/src/main/java/org/citrusframework/yaks/jbang/commands/ListTests.java b/java/tools/yaks-jbang/src/main/java/org/citrusframework/yaks/jbang/commands/ListTests.java index 6475277d..bbcd8cb6 100644 --- a/java/tools/yaks-jbang/src/main/java/org/citrusframework/yaks/jbang/commands/ListTests.java +++ b/java/tools/yaks-jbang/src/main/java/org/citrusframework/yaks/jbang/commands/ListTests.java @@ -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; @@ -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()) { diff --git a/java/tools/yaks-jbang/src/main/java/org/citrusframework/yaks/jbang/commands/YaksCommand.java b/java/tools/yaks-jbang/src/main/java/org/citrusframework/yaks/jbang/commands/YaksCommand.java index 87bc3ba6..df0a914f 100644 --- a/java/tools/yaks-jbang/src/main/java/org/citrusframework/yaks/jbang/commands/YaksCommand.java +++ b/java/tools/yaks-jbang/src/main/java/org/citrusframework/yaks/jbang/commands/YaksCommand.java @@ -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; } }