// so that == comparisons work as expected
argumentList.add(new String(argument));
}
// wet up a command line for this group
final WriteableCommandLine commandLine = new WriteableCommandLineImpl(group, argumentList);
// pick up any defaults from the model
group.defaults(commandLine);
// process the options as far as possible
final ListIterator iterator = argumentList.listIterator();
Object previous = null;
while (group.canProcess(commandLine, iterator)) {
// peek at the next item and backtrack
final Object next = iterator.next();
iterator.previous();
// if we have just tried to process this instance
if (next == previous) {
// abort
break;
}
// remember previous
previous = next;
group.process(commandLine, iterator);
}
// if there are more arguments we have a problem
if (iterator.hasNext()) {
final String arg = (String) iterator.next();
throw new OptionException(group, ResourceConstants.UNEXPECTED_TOKEN, arg);
}
// no need to validate if the help option is present
if (!commandLine.hasOption(helpOption) && !commandLine.hasOption(helpTrigger)) {
group.validate(commandLine);
}
return commandLine;
}