Basicly refactord the entire project into a modular nature

This commit is contained in:
2025-02-20 23:28:24 +01:00
parent 6935e938a3
commit b892306c09
26 changed files with 340 additions and 145 deletions

11
luancher/build.gradle Normal file
View File

@@ -0,0 +1,11 @@
plugins {
id 'java'
}
group = 'me.zacharias'
version = '1.0-SNAPSHOT'
dependencies {
implementation project(":Display")
implementation project(":API")
}

View File

@@ -0,0 +1,55 @@
package me.zacharias.chat.luancher;
import me.zacharias.chat.api.APIServer;
import me.zacharias.chat.display.Display;
public class Launcher {
public static void main(String[] args) {
boolean serverMode = false;
int port = 39075;
String redirectedOutput = null;
for (int i = 0; i < args.length; i++) {
String arg = args[i].toLowerCase();
String argValue = (i + 1 < args.length) ? args[i + 1] : null;
switch (arg) {
case "-s", "--server" -> serverMode = true;
case "-p", "--port" -> {
if (argValue != null) {
port = Integer.parseInt(argValue);
} else {
System.out.println("Missing argument for -p or --port option");
System.exit(1);
}
}
case "-o", "--output" -> {
if (argValue != null) {
redirectedOutput = argValue;
} else {
System.out.println("Missing argument for -o or --output option");
System.exit(1);
}
}
case "--api" -> {
System.out.println("API available at https://server.4zellen.se:3000/Zacharias/chat_thing/wiki/API-Docs");
return;
}
default -> System.out.println("Unknown argument: " + arg);
}
}
if (redirectedOutput != null && !serverMode) {
System.out.println("Cannot run with a redirected output without running in server mode");
return;
}
if (serverMode) {
System.out.println("Starting in API mode...");
new APIServer(port, redirectedOutput);
} else {
System.out.println("Starting in Display mode...");
new Display();
}
}
}