Set help command to short description and alternatives
- As discussed in https://github.com/AuthMe/AuthMeReloaded/pull/169
This commit is contained in:
@@ -20,6 +20,10 @@ import static fr.xephi.authme.command.FoundResultStatus.INCORRECT_ARGUMENTS;
|
||||
import static fr.xephi.authme.command.FoundResultStatus.MISSING_BASE_COMMAND;
|
||||
import static fr.xephi.authme.command.FoundResultStatus.SUCCESS;
|
||||
import static fr.xephi.authme.command.FoundResultStatus.UNKNOWN_LABEL;
|
||||
import static fr.xephi.authme.command.help.HelpProvider.SHOW_ALTERNATIVES;
|
||||
import static fr.xephi.authme.command.help.HelpProvider.SHOW_CHILDREN;
|
||||
import static fr.xephi.authme.command.help.HelpProvider.SHOW_COMMAND;
|
||||
import static fr.xephi.authme.command.help.HelpProvider.SHOW_DESCRIPTION;
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.Collections.singletonList;
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
@@ -108,7 +112,7 @@ public class HelpCommandTest {
|
||||
CommandDescription commandDescription = mock(CommandDescription.class);
|
||||
given(commandDescription.getLabelCount()).willReturn(1);
|
||||
FoundCommandResult foundCommandResult = new FoundCommandResult(commandDescription, singletonList("authme"),
|
||||
Collections.<String>emptyList(), 0.0, SUCCESS);
|
||||
Collections.emptyList(), 0.0, SUCCESS);
|
||||
given(commandMapper.mapPartsToCommand(sender, arguments)).willReturn(foundCommandResult);
|
||||
|
||||
// when
|
||||
@@ -116,7 +120,8 @@ public class HelpCommandTest {
|
||||
|
||||
// then
|
||||
verify(sender, never()).sendMessage(anyString());
|
||||
verify(helpProvider).outputHelp(sender, foundCommandResult, HelpProvider.SHOW_CHILDREN);
|
||||
verify(helpProvider).outputHelp(sender, foundCommandResult,
|
||||
SHOW_DESCRIPTION | SHOW_COMMAND | SHOW_CHILDREN | SHOW_ALTERNATIVES);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -126,7 +131,7 @@ public class HelpCommandTest {
|
||||
CommandDescription commandDescription = mock(CommandDescription.class);
|
||||
given(commandDescription.getLabelCount()).willReturn(2);
|
||||
FoundCommandResult foundCommandResult = new FoundCommandResult(commandDescription, asList("authme", "getpos"),
|
||||
Collections.<String>emptyList(), 0.0, INCORRECT_ARGUMENTS);
|
||||
Collections.emptyList(), 0.0, INCORRECT_ARGUMENTS);
|
||||
given(commandMapper.mapPartsToCommand(sender, arguments)).willReturn(foundCommandResult);
|
||||
|
||||
// when
|
||||
|
||||
@@ -395,6 +395,24 @@ public class HelpProviderTest {
|
||||
assertThat(lines.get(0), equalTo("Command: /authme register <password> <confirmation>"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldShowAlternativesForRootCommand() {
|
||||
// given
|
||||
CommandDescription command = getCommandWithLabel(commands, "unregister");
|
||||
FoundCommandResult result = newFoundResult(command, Collections.singletonList("unreg"));
|
||||
|
||||
// when
|
||||
helpProvider.outputHelp(sender, result, SHOW_COMMAND | SHOW_ALTERNATIVES);
|
||||
|
||||
// then
|
||||
List<String> lines = getLines(sender);
|
||||
assertThat(lines, hasSize(4));
|
||||
assertThat(lines.get(0), equalTo("Header"));
|
||||
assertThat(lines.get(1), equalTo("Command: /unreg <player>"));
|
||||
assertThat(lines.get(2), equalTo("Alternatives:"));
|
||||
assertThat(lines.get(3), equalTo(" /unregister <player>"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an instance of {@link FoundCommandResult} with the given command and labels. All other fields aren't
|
||||
* retrieved by {@link HelpProvider} and so are initialized to default values for the tests.
|
||||
|
||||
Reference in New Issue
Block a user