add version option
This commit is contained in:
@@ -14,8 +14,15 @@ public class Main {
|
|||||||
public static String mcVersion;
|
public static String mcVersion;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
mcVersion = "1.12.2";
|
if(mcVersion == null) {
|
||||||
|
mcVersion = "1.12.2";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(!isVersionValid()) {
|
||||||
|
Log.e("main", "the version number provided is invalid");
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
checkModsDirectory();
|
checkModsDirectory();
|
||||||
new DatabaseVersionManager().updateIfNeeded();
|
new DatabaseVersionManager().updateIfNeeded();
|
||||||
interpretArgs(args);
|
interpretArgs(args);
|
||||||
@@ -65,15 +72,17 @@ public class Main {
|
|||||||
verbose = true;
|
verbose = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "-version":
|
||||||
|
checkNext(it);
|
||||||
|
mcVersion = it.next();
|
||||||
|
break;
|
||||||
|
|
||||||
case "--thread":
|
case "--thread":
|
||||||
if (threadNb != null) {
|
if (threadNb != null) {
|
||||||
Log.e("main", "error conflicting arguments --thread and -t");
|
Log.e("main", "error conflicting arguments --thread and -t");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
if (!it.hasNext()) {
|
checkNext(it);
|
||||||
Log.e("main", "arguments invalid please refer to --help");
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
String threadNumber = it.next();
|
String threadNumber = it.next();
|
||||||
if (threadNumber.matches("[0-9]*")) {
|
if (threadNumber.matches("[0-9]*")) {
|
||||||
threadNb = Integer.valueOf(Integer.parseInt(threadNumber));
|
threadNb = Integer.valueOf(Integer.parseInt(threadNumber));
|
||||||
@@ -93,4 +102,22 @@ public class Main {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isVersionValid() {
|
||||||
|
switch(mcVersion.split(".").length) {
|
||||||
|
case 2:
|
||||||
|
return mcVersion.matches("[0-9]*\\.[0-9]*");
|
||||||
|
case 3:
|
||||||
|
return mcVersion.matches("[0-9]*\\.[0-9]*\\.[0-9]*");
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void checkNext(Iterator<String> it) {
|
||||||
|
if (!it.hasNext()) {
|
||||||
|
Log.e("main", "arguments invalid please refer to --help");
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user