From bbea72ed47ccde96a4200382e4ea67e277cd5378 Mon Sep 17 00:00:00 2001 From: zaaarf Date: Sun, 27 Aug 2023 09:44:38 +0200 Subject: feat: handling custom args --- .../ftbsc/lll/mapper/writer/MappingWriter.java | 30 +++++++++++++++------- .../ftbsc/lll/mapper/writer/impl/TinyV2Writer.java | 2 +- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/main/java/ftbsc/lll/mapper/writer/MappingWriter.java b/src/main/java/ftbsc/lll/mapper/writer/MappingWriter.java index 2cc8007..a884b3a 100644 --- a/src/main/java/ftbsc/lll/mapper/writer/MappingWriter.java +++ b/src/main/java/ftbsc/lll/mapper/writer/MappingWriter.java @@ -8,10 +8,7 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.ServiceLoader; +import java.util.*; /** * Writes a mapping to a certain format. @@ -31,9 +28,24 @@ public class MappingWriter { CommandLine cmdLine = parser.parse(options, args); args = cmdLine.getArgs(); - if(args.length != 3) { + //separate normal args from custom args + int cursor; + for(cursor = 0; cursor < args.length; cursor++) + if(args[cursor].equals("-a")) + break; + String[] customArgs; + if(cursor != args.length) { + int len = args.length - cursor - 1; + customArgs = new String[len]; + System.arraycopy(args, cursor + 1, customArgs, 0, len); + String[] newArgs = new String[cursor]; + System.arraycopy(args, 0, newArgs, 0, cursor); + args = newArgs; + } else customArgs = new String[0]; + + if(args.length < 4) { System.err.println("Bad argument count!"); - System.err.println("java -jar mapping-writer.jar [-r] "); + System.err.println("java -jar mapping-writer.jar [-r] [-a { writer.printf("c\t%s\t%s\n", name, data.nameMapped); data.getFields().forEach((fieldName, fieldData) -> -- cgit v1.2.3-56-ga3b1