From 67be103c42187d087c95b5906400e0bd74bbe9b2 Mon Sep 17 00:00:00 2001 From: punchready Date: Mon, 7 Jun 2021 01:02:40 +0200 Subject: [PATCH] feat: add help cli arg and add descriptions --- .../uulm/teamname/marvelous/server/Server.java | 17 ++++++++++++----- .../marvelous/server/args/ServerArgs.java | 17 +++++------------ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Server/src/main/java/uulm/teamname/marvelous/server/Server.java b/Server/src/main/java/uulm/teamname/marvelous/server/Server.java index 6306c46..48b1345 100644 --- a/Server/src/main/java/uulm/teamname/marvelous/server/Server.java +++ b/Server/src/main/java/uulm/teamname/marvelous/server/Server.java @@ -29,23 +29,30 @@ import java.util.Map; */ public class Server { private static PartyConfig partyConfig; - private static ScenarioConfig scenarioConfig; private static CharacterConfig characterConfig; + private static Integer maxLobbies; public static void main(String[] args) { ServerArgs serverArgs = new ServerArgs(); + JCommander jc = JCommander.newBuilder() + .addObject(serverArgs) + .build(); try { - JCommander.newBuilder() - .addObject(serverArgs) - .build() - .parse(args); + jc.parse(args); } catch (ParameterException e) { Logger.error("Invalid parameters: {}", e.getMessage()); System.exit(1); + return; + } + + if(serverArgs.isHelp()) { + jc.usage(); + System.exit(0); + return; } // System.out.println(serverArgs); diff --git a/Server/src/main/java/uulm/teamname/marvelous/server/args/ServerArgs.java b/Server/src/main/java/uulm/teamname/marvelous/server/args/ServerArgs.java index e398b3d..3cbd275 100644 --- a/Server/src/main/java/uulm/teamname/marvelous/server/args/ServerArgs.java +++ b/Server/src/main/java/uulm/teamname/marvelous/server/args/ServerArgs.java @@ -11,18 +11,11 @@ public class ServerArgs { private boolean help; /** Defines the log level for the current execution of the Server */ - @Parameter(names = {"-l", "--log-level"}, description = """ - Log Level - 0: None - 1: Error - 2: Warning - 3: Info (default) - 4: debug - 5: trace""") + @Parameter(names = {"-l", "--log-level"}, description = "Log Level: 0 = None, 1 = Error, 2 = Warning, 3 = Info, 4 = Debug, 5 = Trace") private Integer logLevel = 3; /** Equivalent to logLevel = 5. Maximum log level (trace) for everything */ - @Parameter(names = {"-v", "--verbose"}) + @Parameter(names = {"-v", "--verbose"}, description = "Enables all log messages") private boolean verbose = false; /** Port that the server listens on */ @@ -42,14 +35,14 @@ public class ServerArgs { private File scenarioConfigFile; /** Whether the server only checks the configuration files, and then stops execution */ - @Parameter(names = {"-C", "--check-conf", "--check-config"}) + @Parameter(names = {"-C", "--check-conf", "--check-config"}, description = "Validates the given config files and exits") private boolean checkConfig = false; /** The path to the folder in which replays are saved */ - @Parameter(names = {"--replay", "-r"}) + @Parameter(names = {"--replay", "-r"}, description = "Path for replay files to be saved at") private String folderPath; - @Parameter(names = {"--max-lobbies", "-L", "--team25-max-lobbies"} ) + @Parameter(names = {"--max-lobbies", "-L", "--team25-max-lobbies"}, description = "Maximum amount of lobbies that can be created") private int maxLobbies = 8; /** Whether help is requested */