Permalink
Browse files

Fix flag parsing to allow non-counting left over args before flags

  • Loading branch information...
masonsbro committed Jun 12, 2013
1 parent db6856b commit 9d915423e382ca2e40e61bbd5729f9b2a61e5aee
Showing with 2 additions and 10 deletions.
  1. +2 −10 src/main/java/com/sk89q/mclauncher/util/BasicArgsParser.java
@@ -42,19 +42,12 @@ public ArgsContext parse(String[] args) {
List<String> leftOver = new ArrayList<String>();
Set<String> flags = new HashSet<String>();
Map<String, String> values = new HashMap<String, String>();
-
- boolean processingFlags = true;
+
String wantingFlag = null;
-
+
for (int i = 0; i < args.length; i++) {
String arg = args[i];
if (arg.startsWith("-")) {
- if (!processingFlags) {
- throw new IllegalArgumentException("Flags must come first");
- }
- if (arg.length() == 1) {
- throw new IllegalArgumentException("Flag with no name");
- }
String flag = arg.substring(1);
if (valueArgs.contains(flag)) {
wantingFlag = flag;
@@ -67,7 +60,6 @@ public ArgsContext parse(String[] args) {
values.put(wantingFlag, arg);
wantingFlag = null;
} else {
- processingFlags = false;
leftOver.add(arg);
}
}

0 comments on commit 9d91542

Please sign in to comment.