Fix inconsistent unknown option parsing
- Fix an issue where unknown option is wrongly lexed as an argument if it's later than an known valid option. - Essentially if `arg1` is only valid option `--arg1 value1 --arg2 value2` would not complain about `arg2`. - Fixes #1120
This commit is contained in:
@@ -222,7 +222,13 @@ public interface Lexer {
|
||||
}
|
||||
}
|
||||
else if (isLastTokenOfType(tokenList, TokenType.ARGUMENT)) {
|
||||
tokenList.add(Token.of(argument, TokenType.ARGUMENT, i2));
|
||||
int decuceArgumentStyle = decuceArgumentStyle(argument);
|
||||
if (decuceArgumentStyle < 0) {
|
||||
tokenList.add(Token.of(argument, TokenType.ARGUMENT, i2));
|
||||
}
|
||||
else {
|
||||
tokenList.add(Token.of(argument, TokenType.OPTION, i2));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user