Treat any trailing space as "a yet to be finished command" instead of a maybe valid argument
This commit is contained in:
parent
6e61fef225
commit
4d91bc6e7e
3 changed files with 14 additions and 6 deletions
|
@ -3,7 +3,7 @@ import groovy.io.FileType
|
||||||
apply plugin: 'java-library'
|
apply plugin: 'java-library'
|
||||||
apply plugin: 'maven'
|
apply plugin: 'maven'
|
||||||
|
|
||||||
version = '0.1.2'
|
version = '0.1.3'
|
||||||
group = 'com.mojang'
|
group = 'com.mojang'
|
||||||
|
|
||||||
task wrapper(type: Wrapper) {
|
task wrapper(type: Wrapper) {
|
||||||
|
|
|
@ -152,10 +152,8 @@ public class CommandDispatcher<S> {
|
||||||
}
|
}
|
||||||
|
|
||||||
context.withCommand(child.getCommand());
|
context.withCommand(child.getCommand());
|
||||||
if (reader.canRead()) {
|
if (reader.canRead(2)) {
|
||||||
if (reader.canRead(2)) {
|
reader.skip();
|
||||||
reader.skip();
|
|
||||||
}
|
|
||||||
if (child.getRedirect() != null) {
|
if (child.getRedirect() != null) {
|
||||||
final CommandContextBuilder<S> childContext = new CommandContextBuilder<>(this, source, reader.getCursor());
|
final CommandContextBuilder<S> childContext = new CommandContextBuilder<>(this, source, reader.getCursor());
|
||||||
childContext.withNode(child.getRedirect(), new StringRange(reader.getCursor(), reader.getCursor()));
|
childContext.withNode(child.getRedirect(), new StringRange(reader.getCursor(), reader.getCursor()));
|
||||||
|
|
|
@ -175,7 +175,7 @@ public class CommandDispatcherTest {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Test
|
@Test
|
||||||
public void testParseIncomplete() throws Exception {
|
public void testParseIncompleteLiteral() throws Exception {
|
||||||
subject.register(literal("foo").then(literal("bar").executes(command)));
|
subject.register(literal("foo").then(literal("bar").executes(command)));
|
||||||
|
|
||||||
final ParseResults<Object> parse = subject.parse("foo ", source);
|
final ParseResults<Object> parse = subject.parse("foo ", source);
|
||||||
|
@ -183,6 +183,16 @@ public class CommandDispatcherTest {
|
||||||
assertThat(parse.getContext().getNodes().size(), is(1));
|
assertThat(parse.getContext().getNodes().size(), is(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Test
|
||||||
|
public void testParseIncompleteArgument() throws Exception {
|
||||||
|
subject.register(literal("foo").then(argument("bar", integer()).executes(command)));
|
||||||
|
|
||||||
|
final ParseResults<Object> parse = subject.parse("foo ", source);
|
||||||
|
assertThat(parse.getReader().getRemaining(), equalTo(" "));
|
||||||
|
assertThat(parse.getContext().getNodes().size(), is(1));
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteAmbiguiousParentSubcommand() throws Exception {
|
public void testExecuteAmbiguiousParentSubcommand() throws Exception {
|
||||||
|
|
Loading…
Reference in a new issue