Skip to content

Commit

Permalink
feat: bump 0.2.3 +b
Browse files Browse the repository at this point in the history
  • Loading branch information
CoolLoong committed May 25, 2024
1 parent 6f97576 commit e0e8d8e
Show file tree
Hide file tree
Showing 18 changed files with 24 additions and 68 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

<groupId>cn.powernukkitx</groupId>
<artifactId>PNX-CLI</artifactId>
<version>0.2.2</version>
<version>0.2.3</version>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/cn/powernukkitx/cli/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import cn.powernukkitx.cli.cmd.StartCommand;
import cn.powernukkitx.cli.cmd.SysInstallCommand;
import cn.powernukkitx.cli.share.CLIConstant;
import cn.powernukkitx.cli.util.*;
import picocli.CommandLine;
import picocli.CommandLine.Command;
Expand Down Expand Up @@ -58,7 +57,6 @@ public Integer call() {
return 1;
}
start.generateOnly = false;
start.restart = true;
var ret = start.call();
if (ret != 0) {
InputUtils.pressEnterToContinue();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package cn.powernukkitx.cli.share;
package cn.powernukkitx.cli;

import cn.powernukkitx.cli.util.OSUtils;

import java.io.File;
import java.util.List;

public interface CLIConstant {
String version = "0.2.1";
String version = "0.2.3";
List<String> authors = List.of("超神的冰凉", "CoolLoong");
File userDir = new File(System.getProperty("user.dir"));
File programDir = new File(OSUtils.getProgramDir());
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/powernukkitx/cli/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public final class Main {
static Timer timer = null;
public static boolean pnxRunning = false;
public static volatile boolean pnxRunning = false;

public static void main(String[] args) {
AnsiConsole.systemInstall();
Expand Down
16 changes: 5 additions & 11 deletions src/main/java/cn/powernukkitx/cli/cmd/StartCommand.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package cn.powernukkitx.cli.cmd;

import cn.powernukkitx.cli.CLIConstant;
import cn.powernukkitx.cli.Main;
import cn.powernukkitx.cli.data.builder.JVMStartCommandBuilder;
import cn.powernukkitx.cli.data.locator.GraalJITLocator;
import cn.powernukkitx.cli.data.locator.GraalModuleLocator;
import cn.powernukkitx.cli.data.locator.JarLocator;
import cn.powernukkitx.cli.data.locator.JavaLocator;
import cn.powernukkitx.cli.share.CLIConstant;
import cn.powernukkitx.cli.util.*;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
Expand Down Expand Up @@ -43,9 +43,6 @@ public final class StartCommand implements Callable<Integer> {
@Override
public Integer call() {
var cmdBuilder = new JVMStartCommandBuilder();
if (args != null && args.length > 0) {
cmdBuilder.setOtherArgs(args);
}
var javaList = new JavaLocator("21", true).locate();
if (javaList.isEmpty()) {
Logger.error(ansi().fgBrightRed().a(new Formatter().format(bundle.getString("no-java21"), OSUtils.getProgramName())).fgDefault());
Expand Down Expand Up @@ -90,7 +87,7 @@ public Integer call() {
} catch (IOException e) {
throw new RuntimeException(e);
}
}else {
} else {
Logger.warn(ansi().fgBrightRed().a(new Formatter().format(bundle.getString("no-libs"), OSUtils.getProgramName())).fgDefault());
return 1;
}
Expand Down Expand Up @@ -128,6 +125,9 @@ public Integer call() {
for (var module : graalModules) {
cmdBuilder.addModulePath(module.getFile().getAbsolutePath());
}
for (var each : ConfigUtils.vmParams()) {
cmdBuilder.addOtherArgs(each);
}
for (var each : ConfigUtils.addOpens()) {
cmdBuilder.addAddOpen(each);
}
Expand Down Expand Up @@ -194,12 +194,6 @@ private int start() {
}
var process = builder.start();
Main.pnxRunning = true;
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
if (process.isAlive()) {
process.destroy();
Main.pnxRunning = false;
}
}));
if (useStdinFile) {
var stdinFile = new File(CLIConstant.userDir, stdin);
if (stdinFile.exists() && stdinFile.isFile() && stdinFile.canRead() && stdinFile.canWrite()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package cn.powernukkitx.cli.data.locator;

import cn.powernukkitx.cli.share.CLIConstant;
import cn.powernukkitx.cli.CLIConstant;

import java.io.File;
import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package cn.powernukkitx.cli.data.locator;

import cn.powernukkitx.cli.share.CLIConstant;
import cn.powernukkitx.cli.CLIConstant;

import java.io.File;
import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package cn.powernukkitx.cli.data.locator;

import cn.powernukkitx.cli.share.CLIConstant;
import cn.powernukkitx.cli.CLIConstant;
import cn.powernukkitx.cli.util.CollectionUtils;
import cn.powernukkitx.cli.util.ConfigUtils;
import cn.powernukkitx.cli.util.StringUtils;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cn.powernukkitx.cli.data.locator;

import cn.powernukkitx.cli.CLIConstant;
import cn.powernukkitx.cli.data.remote.VersionListHelper;
import cn.powernukkitx.cli.share.CLIConstant;

import java.io.File;
import java.io.IOException;
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/cn/powernukkitx/cli/util/ConfigUtils.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cn.powernukkitx.cli.util;

import cn.powernukkitx.cli.share.CLIConstant;
import cn.powernukkitx.cli.CLIConstant;
import cn.powernukkitx.cli.Main;
import com.sun.management.OperatingSystemMXBean;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand All @@ -21,6 +22,7 @@ public final class ConfigUtils {
public static void init() {
parseConfigFile(globalConfigFile);
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
Main.pnxRunning = false;
if (hasChanged.get()) {
try (var writer = new BufferedWriter(new FileWriter(globalConfigFile))) {
INIParser.writeINI(configMap, writer);
Expand Down Expand Up @@ -127,6 +129,11 @@ public static String maxVMMemory() {
}
}

public static String[] vmParams() {
return Arrays.stream(configMap.getOrDefault("vmParams", "").split(" "))
.filter(e -> !e.isBlank()).distinct().toArray(String[]::new);
}

public static String[] addOpens() {
return Arrays.stream(configMap.getOrDefault("add-opens", "").split(" "))
.filter(e -> !e.isBlank()).distinct().toArray(String[]::new);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/powernukkitx/cli/util/OSUtils.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package cn.powernukkitx.cli.util;

import cn.powernukkitx.cli.share.CLIConstant;
import cn.powernukkitx.cli.CLIConstant;

import java.io.*;
import java.nio.charset.Charset;
Expand Down
5 changes: 0 additions & 5 deletions src/main/resources/cn/powernukkitx/cli/App_zh.properties

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit e0e8d8e

Please sign in to comment.