4
0
Fork 0
mirror of https://github.com/Anvilcraft/modpacktools synced 2024-11-17 23:41:55 +01:00

add command interpreter

all commands will now get the full args passsed in for more freedom
This commit is contained in:
LordMZTE 2020-05-01 18:52:07 +02:00
parent 6f7bfc2303
commit 05d4919bc4
3 changed files with 50 additions and 15 deletions

View file

@ -6,7 +6,7 @@ public class Commands {
* Prints out all available commands * Prints out all available commands
*/ */
public static void help() { public static void help() {
System.out.println("Help Goes here!");
} }
/** /**
@ -22,7 +22,7 @@ public class Commands {
* Adds a mod to the modpack * Adds a mod to the modpack
* @param modlink Can be a link to a curseforge file or to a file download * @param modlink Can be a link to a curseforge file or to a file download
*/ */
public static void addMod(String modlink) { public static void addMod(String[] modlink) {
} }
@ -51,7 +51,7 @@ public class Commands {
* Builds the modpack as a server * Builds the modpack as a server
* @param dir The directory where to create the server * @param dir The directory where to create the server
*/ */
public static void buildServer(String dir) { public static void buildServer(String[] dir) {
} }
@ -59,7 +59,7 @@ public class Commands {
* Downloads all mods in this pack * Downloads all mods in this pack
* @param dir The mods directory * @param dir The mods directory
*/ */
public static void downloadMods(String dir) { public static void downloadMods(String[] dir) {
} }
@ -67,7 +67,7 @@ public class Commands {
* Creates a modlist of this pack * Creates a modlist of this pack
* @param format Can be html or csv * @param format Can be html or csv
*/ */
public static void createModlist(String format) { public static void createModlist(String[] format) {
} }
@ -75,10 +75,9 @@ public class Commands {
/** /**
* Creates a server from a modpack zip file * Creates a server from a modpack zip file
* @param modpackZip The path to the zip file * @param args The path to the zip file, The directory where to create the server
* @param dir The directory where to create the server
*/ */
public static void makeServer(String modpackZip, String dir) { public static void makeServer(String[] args) {
} }

View file

@ -3,9 +3,46 @@ package ley.anvil.modpacktools;
import ley.anvil.modpacktools.util.Config; import ley.anvil.modpacktools.util.Config;
public class Main { public class Main {
public static final Config CONFIG = new Config(); public static final Config CONFIG = new Config();
public static void main(String[] args) {
} public static void main(String[] args) {
if(args.length == 0) {
Commands.help();
return;
}
switch(args[0].toLowerCase() /* ignores case of commands */) {
case "help":
default:
Commands.help();
break;
case "init":
Commands.init();
break;
case "addmod":
Commands.addMod(args);
break;
case "buildtwitch":
Commands.buildTwitch();
break;
case "buildmodpackjson":
Commands.buildModpackJSON();
break;
case "buildraw":
Commands.buildRaw();
break;
case "buildserver":
Commands.buildServer(args);
break;
case "downloadmods":
Commands.downloadMods(args);
break;
case "createmodlist":
Commands.createModlist(args);
break;
case "makeserver":
Commands.makeServer(args);
break;
}
}
} }

View file

@ -2,10 +2,8 @@ package ley.anvil.modpacktools.util;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import com.squareup.moshi.Json;
import java.io.*; import java.io.*;
import java.net.JarURLConnection;
import java.net.URISyntaxException; import java.net.URISyntaxException;
public class Config { public class Config {
@ -36,8 +34,9 @@ public class Config {
CONFIG = readConfig(); CONFIG = readConfig();
} }
/* /**
Read The Config if it exist and otherwise copies it from resources * reads the config it it exists and otherwise copies it
* @return the json object of the config file
*/ */
private JsonObject readConfig() { private JsonObject readConfig() {
if(CONFIG_LOCATION.exists()) { if(CONFIG_LOCATION.exists()) {