commit 6a3c77ce62576f0ccbe4b816c1e61b1af125a776 Author: Chaoscaot Date: Sat Jan 1 21:24:10 2022 +0100 Initial Commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b42b1be --- /dev/null +++ b/.gitignore @@ -0,0 +1,87 @@ +### Maven template +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +# https://github.com/takari/maven-wrapper#usage-without-binary-jar +.mvn/wrapper/maven-wrapper.jar + +### JetBrains template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser +./.idea + diff --git a/.idea/sonarlint/issuestore/index.pb b/.idea/sonarlint/issuestore/index.pb new file mode 100644 index 0000000..e69de29 diff --git a/config.json b/config.json new file mode 100644 index 0000000..8f0d4a6 --- /dev/null +++ b/config.json @@ -0,0 +1,11 @@ +{ + "projectPath": "~/IdeaProjects/", + "libPath": "~/libs/", + "defaultName": "default", + "libUrl": "https://steamwar.de/lib.php", + "additionalArgs": ["-d"], + "credentials": { + "username": "[EnterName]", + "password": "[EnterPW]" + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..83d15b9 --- /dev/null +++ b/pom.xml @@ -0,0 +1,92 @@ + + + 4.0.0 + + de.chaos + swlnmngr + 1.0-SNAPSHOT + SteamWarLinkManager + + + 17 + 17 + + + + clean package + + + org.apache.maven.plugins + maven-shade-plugin + + + + shade + + + true + + + de.chaos.swlnmngr.Main + + + ${name} + + + + + + + + src/main/resources + + *.* + + false + + + ${name}-noshade + + + + + org.json + json + 20211205 + + + junit + junit + 4.13.2 + test + + + org.projectlombok + lombok + 1.18.22 + + + commons-cli + commons-cli + 1.5.0 + + + org.apache.logging.log4j + log4j-api + 2.17.1 + + + org.apache.logging.log4j + log4j-core + 2.17.1 + + + org.apache.httpcomponents + httpclient + 4.5.13 + + + \ No newline at end of file diff --git a/src/main/java/de/chaos/swlnmngr/Main.java b/src/main/java/de/chaos/swlnmngr/Main.java new file mode 100644 index 0000000..dddcc2e --- /dev/null +++ b/src/main/java/de/chaos/swlnmngr/Main.java @@ -0,0 +1,30 @@ +package de.chaos.swlnmngr; + +import de.chaos.swlnmngr.config.CLIConfig; +import de.chaos.swlnmngr.config.Config; +import lombok.Getter; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.core.config.Configurator; + +import java.util.Arrays; + +public class Main { + + @Getter + private static final Logger logger = LogManager.getLogger(Main.class); + @Getter + private static String[] allArgs; + + public static void main(String[] args) { + logger.log(Level.INFO, "SteamWarLinkManager by Chaoscaot"); + allArgs = new String[args.length + Config.ADDITIONAL_ARGS.length]; + System.arraycopy(args, 0, allArgs, 0, args.length); + System.arraycopy(Config.ADDITIONAL_ARGS, 0, allArgs, args.length, Config.ADDITIONAL_ARGS.length); + if(CLIConfig.IS_DEBUG) { + Configurator.setRootLevel(Level.DEBUG); + } + logger.debug("Arguments: {}", Arrays.toString(allArgs)); + } +} diff --git a/src/main/java/de/chaos/swlnmngr/config/CLIConfig.java b/src/main/java/de/chaos/swlnmngr/config/CLIConfig.java new file mode 100644 index 0000000..5216278 --- /dev/null +++ b/src/main/java/de/chaos/swlnmngr/config/CLIConfig.java @@ -0,0 +1,33 @@ +package de.chaos.swlnmngr.config; + +import de.chaos.swlnmngr.Main; +import org.apache.commons.cli.*; + +public class CLIConfig { + + public static final boolean IS_DEBUG; + public static final boolean UPDATE; + public static final String[] ARGS; + + static { + Options options = new Options(); + options.addOption(new Option("d", "debug", false, "Set the Log Level to Debug")); + options.addOption(new Option("u", "update", false, "Update the Default libs")); + + CommandLine cli = null; + CommandLineParser parser = new DefaultParser(); + HelpFormatter formatter = new HelpFormatter(); + + try { + cli = parser.parse(options, Main.getAllArgs()); + } catch (ParseException e) { + Main.getLogger().error(e.getMessage()); + formatter.printHelp("swlnmngr", options, true); + System.exit(1); + } + + ARGS = cli.getArgs(); + IS_DEBUG = cli.hasOption("d"); + UPDATE = cli.hasOption("u"); + } +} diff --git a/src/main/java/de/chaos/swlnmngr/config/Config.java b/src/main/java/de/chaos/swlnmngr/config/Config.java new file mode 100644 index 0000000..7008d8f --- /dev/null +++ b/src/main/java/de/chaos/swlnmngr/config/Config.java @@ -0,0 +1,37 @@ +package de.chaos.swlnmngr.config; + +import de.chaos.swlnmngr.Main; +import org.json.JSONObject; +import org.json.JSONTokener; + +import java.io.File; +import java.io.FileInputStream; +import java.nio.file.Files; +import java.nio.file.StandardOpenOption; + +public class Config { + + private static final File CONFIG_FILE = new File("config.json"); + + public static final String[] ADDITIONAL_ARGS; + + static { + JSONObject config = null; + try { + if(!CONFIG_FILE.exists()) { + Files.write(CONFIG_FILE.toPath(), Config.class.getResourceAsStream("/default_config.json").readAllBytes(), StandardOpenOption.CREATE_NEW); + } + + config = new JSONObject(new JSONTokener(new FileInputStream(CONFIG_FILE))); + } catch (Exception e) { + Main.getLogger().fatal("Could not load Config", e); + System.exit(1); + } + + ADDITIONAL_ARGS = config.getJSONArray("additionalArgs").toList().toArray(new String[0]); + } + + public static void reset() { + + } +} diff --git a/src/main/java/de/chaos/swlnmngr/route/Router.java b/src/main/java/de/chaos/swlnmngr/route/Router.java new file mode 100644 index 0000000..70bf301 --- /dev/null +++ b/src/main/java/de/chaos/swlnmngr/route/Router.java @@ -0,0 +1,4 @@ +package de.chaos.swlnmngr.route; + +public class Router { +} diff --git a/src/main/java/de/chaos/swlnmngr/route/routes/Route.java b/src/main/java/de/chaos/swlnmngr/route/routes/Route.java new file mode 100644 index 0000000..d9790f1 --- /dev/null +++ b/src/main/java/de/chaos/swlnmngr/route/routes/Route.java @@ -0,0 +1,7 @@ +package de.chaos.swlnmngr.route.routes; + +public interface Route { + String getName(); + + boolean route(String[] args); +} diff --git a/src/main/java/de/chaos/swlnmngr/route/routes/Routes.java b/src/main/java/de/chaos/swlnmngr/route/routes/Routes.java new file mode 100644 index 0000000..6822cf1 --- /dev/null +++ b/src/main/java/de/chaos/swlnmngr/route/routes/Routes.java @@ -0,0 +1,5 @@ +package de.chaos.swlnmngr.route.routes; + +public enum Routes { + +} diff --git a/src/main/resources/default_config.json b/src/main/resources/default_config.json new file mode 100644 index 0000000..1ea9b61 --- /dev/null +++ b/src/main/resources/default_config.json @@ -0,0 +1,11 @@ +{ + "projectPath": "~/IdeaProjects/", + "libPath": "~/libs/", + "defaultName": "default", + "libUrl": "https://steamwar.de/lib.php", + "additionalArgs": [], + "credentials": { + "username": "[EnterName]", + "password": "[EnterPW]" + } +} \ No newline at end of file diff --git a/src/main/resources/default_swlnmngr.bat b/src/main/resources/default_swlnmngr.bat new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/default_swlnmngr.sh b/src/main/resources/default_swlnmngr.sh new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml new file mode 100644 index 0000000..48a08a3 --- /dev/null +++ b/src/main/resources/log4j2.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file