in core/container/src/main/java/org/wildfly/swarm/cli/Option.java [277:330]
boolean parse(ParseState state, CommandLine commandLine) throws Exception {
String cur = state.la();
if (cur == null) {
return false;
}
String value = null;
String matchedArg = null;
if (this.shortArg != null && cur.startsWith(HYPHEN + this.shortArg)) {
matchedArg = HYPHEN + this.shortArg;
if (hasValue() && cur.length() >= 3) {
if (cur.charAt(2) == '=') {
value = cur.substring(3);
} else {
value = cur.substring(2);
}
}
} else if (this.longArg != null && cur.startsWith(DOUBLE_HYPHEN + this.longArg)) {
matchedArg = DOUBLE_HYPHEN + this.longArg;
if (hasValue() && cur.length() >= this.longArg.length() + 3) {
if (cur.charAt(this.longArg.length() + 2) == '=') {
value = cur.substring(this.longArg.length() + 3);
} else {
value = cur.substring(this.longArg.length() + 2);
}
}
} else {
return false;
}
state.consume();
if (value != null && value.trim().isEmpty()) {
value = null;
}
if (hasValue() && value == null && !this.valueMayBeSeparate) {
throw SwarmMessages.MESSAGES.argumentRequired(matchedArg);
}
if (hasValue() && value == null) {
if (state.la() == null) {
throw SwarmMessages.MESSAGES.argumentRequired(matchedArg);
}
value = state.consume();
}
this.action.set(commandLine, this, value);
return true;
}