Parse into nested arguments

This commit is contained in:
Nathan Adams
2014-09-18 16:36:36 +02:00
parent a32243b704
commit 8d164e4b66
8 changed files with 97 additions and 17 deletions
@@ -22,6 +22,23 @@ public class ArgumentCommandNode<T> extends CommandNode {
@Override
public void parse(String command) throws IllegalCommandArgumentException {
type.parse(command);
CommandArgumentType.CommandArgumentParseResult<T> parsed = type.parse(command);
int start = parsed.getRaw().length() + 1;
if (start < command.length()) {
String result = command.substring(start);
IllegalCommandArgumentException exception = new IllegalCommandArgumentException();
for (CommandNode node : getChildren()) {
try {
node.parse(result);
return;
} catch (IllegalCommandArgumentException ex) {
exception = ex;
}
}
throw exception;
}
}
}