Skip to content

Commit

Permalink
Merge pull request #50 from masonsbro/master
Browse files Browse the repository at this point in the history
Updated BasicArgsParser to allow non-flag arguments to appear in places other than the end.
  • Loading branch information
sk89q committed Jun 13, 2013
2 parents 479ef5e + 2c5e931 commit 5364a07
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/main/java/com/sk89q/mclauncher/util/BasicArgsParser.java
Expand Up @@ -42,16 +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");
}
Expand All @@ -67,7 +63,6 @@ public ArgsContext parse(String[] args) {
values.put(wantingFlag, arg);
wantingFlag = null;
} else {
processingFlags = false;
leftOver.add(arg);
}
}
Expand Down

0 comments on commit 5364a07

Please sign in to comment.