Skip to content

Commit d674eb8

Browse files
committed
Add --cfg option to allow passing in arguments by file.
Update SrgUtils to support gziped map files.
1 parent 0bf28a2 commit d674eb8

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dependencyResolutionManagement {
1616
versionCatalogs {
1717
libs {
1818
library('jopt-simple', 'net.sf.jopt-simple:jopt-simple:6.0-alpha-3')
19-
library('srgutils', 'net.minecraftforge:srgutils:0.5.10')
19+
library('srgutils', 'net.minecraftforge:srgutils:0.6.0')
2020
library('nulls', 'org.jetbrains:annotations:24.0.1')
2121
library('powermock', 'org.powermock:powermock-core:2.0.9')
2222

src/main/java/net/minecraftforge/fart/Main.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
import java.io.PrintStream;
1010
import java.io.FileOutputStream;
1111
import java.nio.file.Files;
12+
import java.nio.file.Path;
1213
import java.nio.file.Paths;
1314
import java.util.ArrayList;
1415
import java.util.Arrays;
1516
import java.util.List;
1617
import java.util.function.Consumer;
18+
import java.util.stream.Stream;
1719

1820
import joptsimple.OptionException;
1921
import joptsimple.OptionParser;
@@ -28,6 +30,36 @@
2830

2931
public class Main {
3032
public static void main(String[] args) throws IOException {
33+
List<String> params = new ArrayList<>();
34+
for (int x = 0; x < args.length; x++) {
35+
if (args[x].startsWith("--cfg")) {
36+
String path = null;
37+
if (args[x].startsWith("--cfg=")) {
38+
path = args[x].substring(6);
39+
} else if (args.length > x + 1) {
40+
path = args[++x];
41+
} else {
42+
System.out.println("Must specify a file when using --cfg argument.");
43+
return;
44+
}
45+
46+
Path file = Paths.get(path);
47+
if (!Files.exists(file)) {
48+
System.out.println("error: missing config '" + path + "'");
49+
return;
50+
}
51+
try (Stream<String> stream = Files.lines(file)) {
52+
stream.forEach(params::add);
53+
} catch (IOException e) {
54+
System.out.println("error: Failed to read config file '" + path + "'");
55+
throw new RuntimeException(e);
56+
}
57+
} else {
58+
params.add(args[x]);
59+
}
60+
}
61+
args = params.toArray(new String[params.size()]);
62+
3163
OptionParser parser = new OptionParser();
3264
OptionSpec<File> inputO = parser.accepts("input", "Input jar file").withRequiredArg().ofType(File.class).required();
3365
OptionSpec<File> outputO = parser.accepts("output", "Output jar file, if unspecifed, overwrites input").withRequiredArg().ofType(File.class);

0 commit comments

Comments
 (0)