Browse files

Implement -args_file option to launcher

  • Loading branch information...
1 parent 9563a81 commit 58df3353bc1366c3802c66121c510d6b8e04db80 @krestenkrab krestenkrab committed Sep 23, 2013
Showing with 30 additions and 0 deletions.
  1. +30 −0 src/main/java/erjang/Main.java
View
30 src/main/java/erjang/Main.java
@@ -18,9 +18,12 @@
package erjang;
+import java.io.BufferedReader;
import java.io.File;
+import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.regex.Pattern;
import sun.misc.Signal;
import sun.misc.SignalHandler;
@@ -100,6 +103,33 @@ public static void main(String[] args) throws Exception {
continue;
}
+ if ("-args_file".equals(args[i]) && i < args.length) {
+
+ BufferedReader br = new BufferedReader(new FileReader(args[i+1]));
+ String line;
+ while ((line = br.readLine()) != null) {
+ line = line.replaceFirst("^ *(#.*)?", "");
+ if (line.isEmpty()) {
+ continue;
+ }
+
+ Pattern p = Pattern.compile("((?<plain>[^ ]+)|\"(?<quoted>([^\"]|\\\\\")*)\") *");
+ java.util.regex.Matcher m = p.matcher(line);
+ while (m.find()) {
+ String a;
+ if ((a=m.group("plain")) != null) {
+ ra.add(a);
+ } else if ((a=m.group("quoted")) != null) {
+ ra.add(a.replace("\\\"", "\""));
+ }
+ }
+ }
+ br.close();
+
+ i++;
+ continue;
+ }
+
if (arg.startsWith("+")) {
switch (arg.charAt(1)) {
case 'a':

0 comments on commit 58df335

Please sign in to comment.