Fixed how optional commands work - we don't find an earlier command in the tree anymore.
This commit is contained in:
parent
9a3f987c97
commit
4af7274892
2 changed files with 3 additions and 5 deletions
|
@ -89,9 +89,7 @@ public class CommandDispatcher<S> {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (child.getCommand() != null) {
|
||||
context.withCommand(child.getCommand());
|
||||
}
|
||||
context.withCommand(child.getCommand());
|
||||
if (remaining.isEmpty()) {
|
||||
return new ParseResults<>(context);
|
||||
} else {
|
||||
|
|
|
@ -49,8 +49,8 @@ public class CommandDispatcherTest {
|
|||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testCreateAndMergeCommands() throws Exception {
|
||||
subject.register(literal("base").then(literal("foo")).executes(command));
|
||||
subject.register(literal("base").then(literal("bar")).executes(command));
|
||||
subject.register(literal("base").then(literal("foo").executes(command)));
|
||||
subject.register(literal("base").then(literal("bar").executes(command)));
|
||||
|
||||
assertThat(subject.execute("base foo", source), is(42));
|
||||
assertThat(subject.execute("base bar", source), is(42));
|
||||
|
|
Loading…
Reference in a new issue