Add --config flag for passing custom config, add --help flag

This commit is contained in:
dginovker 2024-01-21 13:47:55 +09:00
parent 7957cdc8a6
commit a87b92a25a

View file

@ -216,11 +216,38 @@ public final class client extends GameShell {
@OriginalMember(owner = "client!client", name = "main", descriptor = "([Ljava/lang/String;)V") @OriginalMember(owner = "client!client", name = "main", descriptor = "([Ljava/lang/String;)V")
public static void main(@OriginalArg(0) String[] arg0) { public static void main(@OriginalArg(0) String[] arg0) {
try { try {
GlobalJsonConfig.load(GlobalConfig.EXTENDED_CONFIG_PATH); String configPath = GlobalConfig.EXTENDED_CONFIG_PATH;
} catch (Exception ex) { boolean helpRequested = false;
ex.printStackTrace();
} for (int i = 0; i < arg0.length; i++) {
if ("--config".equals(arg0[i]) && i + 1 < arg0.length) {
configPath = arg0[i + 1];
i++; // Skip next argument since it's the config file path
} else if ("--help".equals(arg0[i])) {
helpRequested = true;
}
}
if (helpRequested) {
System.out.println("Usage: java path-to-jar.jra [--config <path>] [--help]");
System.out.println("Custom Options:");
System.out.println(" --config <path> Path to the configuration file.");
System.out.println(" --help Display this help message.");
System.out.println("\nDefault Arguments:");
System.out.println(" worldListId: Identifier for the world list, usually an integer.");
System.out.println(" modeWhat: Operational mode, where 'live' is normal operation, 'rc' for release candidate, and 'wip' for work-in-progress.");
System.out.println(" language: Language setting, like 'english' or 'german'.");
System.out.println(" game: Game version identifier, e.g., 'game0' or 'game1'.");
System.out.println("\nThese arguments are kept for authentic purposes, reflecting original application parameters.");
return;
}
System.out.println("Loading config path " + configPath);
GlobalJsonConfig.load(configPath);
} catch (Exception ex) {
ex.printStackTrace();
}
try { try {
if (arg0.length != 4) { if (arg0.length != 4) {
arg0 = new String[4]; arg0 = new String[4];