Changes the parser to allow argument shorthands of any length
This commit is contained in:
parent
1e3544f793
commit
a0b5b65054
@ -56,8 +56,8 @@ public final class Parser {
|
|||||||
String argumentName = currentToken.substring(2);
|
String argumentName = currentToken.substring(2);
|
||||||
foundArguments = ListUtil.getMatching(converterArguments, (item) -> item.getName().equals(argumentName));
|
foundArguments = ListUtil.getMatching(converterArguments, (item) -> item.getName().equals(argumentName));
|
||||||
} else if (currentToken.startsWith("-")) {
|
} else if (currentToken.startsWith("-")) {
|
||||||
char argumentShorthand = currentToken.substring(1).charAt(0);
|
String argumentShorthand = currentToken.substring(1);
|
||||||
foundArguments = ListUtil.getMatching(converterArguments, (item) -> item.getShorthand() == argumentShorthand);
|
foundArguments = ListUtil.getMatching(converterArguments, (item) -> item.getShorthand().equals(argumentShorthand));
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Unexpected value when not given an argument.");
|
throw new IllegalArgumentException("Unexpected value when not given an argument.");
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,9 @@ public class ParserTest {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
validArguments = new ArrayList<>();
|
validArguments = new ArrayList<>();
|
||||||
validArguments.add(new ConverterArgument("anargument", 'a', true, ConverterArgumentValue.STRING));
|
validArguments.add(new ConverterArgument("anargument", "a", true, ConverterArgumentValue.STRING));
|
||||||
validArguments.add(new ConverterArgument("turnoff", 't', false, ConverterArgumentValue.BOOLEAN));
|
validArguments.add(new ConverterArgument("turnoff", "t", false, ConverterArgumentValue.BOOLEAN));
|
||||||
validArguments.add(new ConverterArgument("turnon", 'o', false, ConverterArgumentValue.BOOLEAN));
|
validArguments.add(new ConverterArgument("turnon", "o", false, ConverterArgumentValue.BOOLEAN));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user